将工具栏添加到 tableView
我正在使用 iPhone 的 XCode 4.3“Master/Detail”模板。在 ROOT 级别,这是一个 UIToolbarController。我想要导航和工具栏。导航很简单 - 模板已经使用 self.navigationItem.leftBarButtonItem (和右侧)来添加按钮,但我找不到添加有用工具栏项目的方法。我可以添加一个工具栏(见下文),但这会添加到表格视图的滚动视图中,因此会随着表格内容上下滚动 - 不是很有用。 tableView.view 没有超级视图,您认为工具栏应该位于该超级视图中。它也没有窗户! (所有这些属性均为空)。
顶部导航栏必须属于某个未滚动的视图,但是什么?!!设置 self.navigationController 的toolbarHidden属性没有任何效果(将navigationBarHidden设置为YES也不会隐藏导航栏)。
显然这里有一些我不明白的事情......
// this toolbar scrolls with the tableview contents!
INavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self];
nvc.toolbarHidden = NO;
[self.view addSubview:nvc.view];
I'm using the XCode 4.3 "Master/Detail" template for the iPhone. At the ROOT level, this is a UIToolbarController. I want navigation and toolbars. The navigation is easy--the template already uses the self.navigationItem.leftBarButtonItem (and right) to add buttons, but I can't find a way to add useful toolbar items. I can add a toolbar (see below), but this gets added to the scroll view of the tableview, so scrolls up and down with the table contents--not very useful. The tableView.view has no superview which is where you'd think a tool bar should go. It has no window either! (all these properties are null).
That top navbar must belong to some view which is not scrolled, but what?!! Setting the toolbarHidden property of self.navigationController has no effect (setting the navigationBarHidden to YES does not hide the nav bar either).
Obviously something I don't understand here...
// this toolbar scrolls with the tableview contents!
INavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self];
nvc.toolbarHidden = NO;
[self.view addSubview:nvc.view];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需突出显示导航控制器,然后查看属性即可。选中“显示工具栏”以取消隐藏已有的工具栏。
Just highlight the navigation controller and then look at the attributes. check "Shows Toolbar" to unhide the toolbar that is already there.