将选项卡栏控制器添加到 UISplitViewController 的根视图?
如何将 UITabBarController 及其所有单独的视图控制器设置为分割视图中的根视图? IB 似乎不允许我将根视图控制器的类更改为其他任何内容......我正在使用 Xcode 4。
How would I set a UITabBarController with all its individual view controllers as the root view in a split view? IB doesn't seem to let me change the class of the root view controller to anything else…I'm using Xcode 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否使用基于分割视图的应用程序选项?在这种情况下,我只需扩展 RootViewController.h 文件中的 UITabBarController 即可。我不确定你在这里想要什么行为,但是如果你像这样设置它,你应该在“root”选项中获得包含所有视图的选项卡栏(你必须将它们添加到 RootViewController.m ofc 中)导航栏。
如果您希望 DetailView 显示相同的内容,则还必须向详细视图添加一个导航控制器。
至于IB的“更优雅”的解决方案,恐怕我对IB不是很喜欢,也不是很有经验。
Are you using the split-view based application-option? In that case, it worked for me to just extend : UITabBarController in the RootViewController.h-file. I'm not sure what behaviour you want here, but if you set it up like that, you should get the tabbar with all your views (you have to add them in RootViewController.m ofc) in the "root"-option on the navigation bar.
If you want the DetailView to show the same, you have to add a navigationcontroller to the detailview as well.
As for the "more elegant" solution with IB, I'm afraid I'm not very fond of or very experienced with IB.
您想将 tabbarcontroller 添加到根视图侧的分割视图中,这非常简单。
使用 xib for ipad 创建尽可能多的 viewcontrollers 子类,因为你想放入 tabbarcontroller 中。
运行程序选择横向然后你可以看到它完成了。
You want to add tabbarcontroller to your split view at rootview side and its very simple.
create as many viewcontrollers subclasses with xib for ipad as u want to put in tabbarcontroller.
run program select landscape then u can see its done.
感谢 dh14-sl 和 lecou——解决方案是你们两个答案的结合。我试图将选项卡栏控制器从库拖到元素列表上,但它不起作用 - 结果我必须将其拖到视图本身。然后我不得不更改 rootvc 的父类并重新设置连接,但现在似乎可以了!谢谢你们!
Thanks to dh14-sl and lecou—the solution was a combination of both your answers. I was trying to drag a tab bar controller from the library onto the list of elements but it wasn't working—turns out I had to drag it to the view itself. Then I had to change the parent class of my rootvc and re-setup connections, but now it seems to work! Thanks guys!