【发布时间】:2010-08-04 02:19:33
【问题描述】:
我有一个顶部有导航栏的应用。在作为 UITableView 子类的一个视图中,我使用以下代码在 UITableView 下方添加了一个 UIToolbar:
UIToolbar *toolbar = [[UIToolbar alloc] init];
[toolbar sizeToFit]; // Set the toolbar to fit the width of the app
CGFloat toolbarHeight = [toolbar frame].size.height; // Calculate the height of the toolbar
CGRect rootViewBounds = self.parentViewController.view.bounds;
CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);
CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);
CGRect rectArea = CGRectMake(0, toolbarHeight, rootViewWidth, toolbarHeight);
[toolbar setFrame:rectArea];
[self.navigationController.view addSubview:toolbar];
问题在于工具栏位于 UITableView 的“顶部”,并且遮盖了 UITableView 第一行内容的顶部。我真正想要的是表格视图在 UIToolbar 下方“开始”。
我如何正确地完成这项工作?
感谢, 何塞
【问题讨论】:
标签: iphone objective-c