将UITabBarController添加到UIViewController [英] Adding UITabBarController to a UIViewController
问题描述
我的应用程序目前有 UINavigationController
,我想在按钮的某个时刻按 UITabBarController
点击。我试图在Interface Builder上创建它(而不是以编程方式)。
My app currently has a UINavigationController
and I'd like to push a UITabBarController
at some point when a button is clicked. I am trying to create it on Interface Builder (as opposed to programatically).
所有在线教程都展示了如何创建基于标签栏的应用程序,其中涉及拖动 UITabBarController
进入 MainWindow.xib
这显然不是我想要的。
All online tutorials show how to create a tab bar based app, which involves dragging a UITabBarController
into the MainWindow.xib
which is obviously not what I want.
我所做的是创建 UIViewController
及其nib文件,拖动 UITabBarController
。现在将 UIViewController
推送到导航控制器将显示一个空视图(其空视图)。删除视图控制器中的视图会使应用程序崩溃。如何告诉 UIViewController
加载 UITabBarController
而不是自己的视图?
What I did was create a UIViewController
, and its nib file, dragged a UITabBarController
. Now pushing that UIViewController
to the navigation controller will show an empty view (its empty view). Removing the view in the view controller will crash the app. How can I tell the UIViewController
to load a UITabBarController
instead of its own view?
对于那些投票给我的人:至少提供评论是不错的。问题不是一个糟糕的问题。问题是询问如何以非正统的方式使用UITabBarController的建议。我尝试了大部分建议而且没有用。如果你是投票,至少写一个评论。
推荐答案
问题是,因为我相信我已经提到过某个地方,就是XIB没有连接到它的UIView。当在XIB文件中删除UIView并添加UITabBarController时,XIB的视图
属性必须连接到 UITabBarController
的观点。我连接它,它工作。这就是我获得SIGTRAP的原因。
The problem was, as I believe I've mentioned somewhere, is that the XIB does not have a UIView connected to it. When the UIView is deleted in a XIB file and a UITabBarController is added, the view
property of the XIB has to be connected to the UITabBarController
's view. I connected it and it worked. That was the reason why I was getting a SIGTRAP.
这篇关于将UITabBarController添加到UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!