2009-05-01 14 views
2

私の視点を構築しようとするのが少し難しいです。すべて私はUIToolBarを私のビューに挿入する必要があるところまで素晴らしいです。私はそれが配置されることを期待した場所にtableViewが配置されます。一方、UIToolBarはテーブルを上下にスクロールしますが、それは固定されていません。それはまた、画面上に置いたときに奇妙に見える - それを配置する計算が正しくないので私は推測している?この質問にはスクリーンショットとこれを構築するために使用したコードが添付されています。私が間違っていることを見つけていただきありがとうございます。スクリーンショット:http://dl-web.dropbox.com/u/57676/screenshots/broketoolbar.pngUIToolBarが私のUITableViewでスクロールするのはなぜですか?

コード:

- (void)loadView 
{ 
    [super loadView]; 
    // TableViews that wish to utilize tableView footers/headers should override this method. 

    UITableView *aTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 
    aTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight); 
    aTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; 

    aTableView.delegate = self; 
    aTableView.dataSource = dataSource; 

    self.tableView = aTableView; 
    self.view = tableView; 
    [aTableView release]; 

    UIToolbar *toolbar = [UIToolbar new]; 
    [toolbar setBarStyle:UIBarStyleBlackOpaque]; 
    [toolbar sizeToFit]; 
    CGFloat toolbarHeight = [toolbar frame].size.height; 
    CGRect mainViewBounds = self.view.bounds; 
    [toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds), 
           CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds) - (toolbarHeight * 2.0), 
           CGRectGetWidth(mainViewBounds), 
           toolbarHeight)]; 
    [self.view insertSubview:toolbar aboveSubview:self.tableView]; 
    [toolbar release]; 
}        

答えて

2

self.viewを使用すると、ツールバーを追加した上でのtableViewですので。

関連する問題