UITableView只占用部分屏幕

时间:2010-01-04 06:14:15

标签: iphone uitableview

我试图制作类似于iCal的自己的日历,除了一件事以外,一切顺利。我计划将日历选择放在顶部,然后将表格列在底部。我可以这样做但是日历与表格在同一子视图中并随之滚动。虽然我目前没有使用笔尖,如果我在笔尖中构建它,那么表格不会调整大小以占用日历中没有的任何内容。也就是说它应该比二月更大,因为十二月会很小(就像苹果iCal版本一样)我见过其他应用程序这样做。关于我将如何处理的任何想法?

1 个答案:

答案 0 :(得分:2)

将tableview和日历视图分别添加到主视图。

示例:

- (void)loadView {
    [super loadView];

    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    topView.backgroundColor = [UIColor darkGrayColor];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 280, 60)];
    label.text = @"Stationary top view";
    label.textColor = [UIColor whiteColor];
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = UITextAlignmentCenter;
    [topView addSubview:label];
    [label release];


    [self.view addSubview:topView];
    [topView release];


    UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 100, 320, 380) style:UITableViewStyleGrouped];
    tableview.delegate = self;
    tableview.dataSource = self;
    [self.view addSubview:tableview];
    [tableview release];
}

屏幕截图:

alt text http://static.benford.name/tableview_with_topview.png

相关问题