将工具栏添加到 tableView

发布于 2024-11-30 23:44:51 字数 682 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-12-07 23:44:51

只需突出显示导航控制器,然后查看属性即可。选中“显示工具栏”以取消隐藏已有的工具栏。

Just highlight the navigation controller and then look at the attributes. check "Shows Toolbar" to unhide the toolbar that is already there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文