[英]Switching UINavigationViewController to UITabBarController with Segues
I am changing my app to use UITabBarController
instead of UINavigationViewController
. 我正在更改我的应用程序以使用
UITabBarController
而不是UINavigationViewController
。 I replaced controllers accordingly and app launches with tabs successfully. 我相应地替换了控制器,并成功使用选项卡启动了应用程序。 Later in the code I came across some difficulties using segues where lines like
稍后在代码中,我遇到了使用segues的一些困难,其中类似
[self performSegueWithIdentifier:@"ImageViewController" sender:self];
won't work producing error 不会产生错误
" Push segues can only be used when the source controller is managed by an instance of UINavigationController " “ 仅当由UINavigationController的实例管理源控制器时,才能使用推送选择 ”
When I embedded UINavigationController
into the initial FirstViewController
, line above worked fine. 当我将
UINavigationController
嵌入到初始的FirstViewController
,上面的行工作正常。 I need that line to switch between views and pass some data to another view controller. 我需要那条线在视图之间切换,并将一些数据传递给另一个视图控制器。
The problem is that using segue identifier to go to SecondViewController
hides TabBar navigation (unless I wrap SecondViewController
in UINavigationController
again and so on). 问题是,使用segue标识符转到
SecondViewController
隐藏TabBar导航(除非我再次将SecondViewController
包装在UINavigationController
,依此类推)。 That is not the solution. 那不是解决方案。
Question : How to use UITabBarController
and still take advantage of segues while keeping tab navigation visible? 问题 :如何在保持选项卡导航可见的情况下如何使用
UITabBarController
并继续使用segue?
"Push segues can only be used when the source controller is managed by an instance of UINavigationController"
“仅当源控制器由UINavigationController的实例管理时,才可以使用推送选择”
Sounds to me like you are using a push
segue somewhere outside a navigation controller. 在我看来,您在导航控制器外部的某个地方使用了
push
播功能。 Try to select all "segue bubbles" in interface builder that are not inside a navigation controller: 尝试在界面生成器中选择不在导航控制器内部的所有“搜索气泡”:
and check the segue's style in the right pane: 并在右侧窗格中检查segue的样式:
If the style is set to the value push
as shown above change it to modal
or custom
: 如果将样式设置为如上所述的值
push
,则将其更改为modal
或custom
:
There is something wrong with your connections. 您的连接有问题。 If you are using interface builder (storyboard) then your connections should look like this.
如果您正在使用界面构建器(storyboard),则您的连接应如下所示。 See pic
见图片
Notice you are missing UINavigation Title headers. 请注意,您缺少UINavigation标题标头。 Also the gray area below on each view controller means that space is reserved for images for UITabBarController
同样,每个视图控制器下方的灰色区域也意味着为UITabBarController的图像保留了空间
Another problem is your UIToolBar. 另一个问题是您的UIToolBar。 Looks like its sitting on top of where UITabBar will be displayed.
看起来像它位于显示UITabBar的顶部。 That may/may not get your app rejected by apple since you already have a UINavigationController and UITabBarController.
因为您已经具有UINavigationController和UITabBarController,所以可能会/可能不会使您的应用程序被苹果拒绝。 If you need more buttons/options on that page make them UIButtons instead.
如果您需要该页面上的更多按钮/选项,请改用UIButtons。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.