2010-01-04 85 views
2

我試圖讓自己的日曆類似於iCal,除了一件事情之外,一切都進行得很順利。我計劃將日曆選擇放在頂部,然後選擇底部的表格列表。我可以做到這一點,但日曆與表格位於同一個子視圖中並隨其滾動。雖然我現在不使用筆尖,如果我將它構建在筆尖上,那麼桌子不會調整大小以適應日曆不能使用的任何東西。即它應該比2月份更大,因爲12月份會很小(完全像蘋果iCal版本),我已經看到其他應用可以做到這一點。關於如何去做這件事的任何想法?UITableView只佔用屏幕的一部分

回答

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

相關問題