iOS:无法将UISplitViewController推送到UINavigationController [英] iOS: UISplitViewController cannot be pushed to UINavigationController

查看:198
本文介绍了iOS:无法将UISplitViewController推送到UINavigationController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用导航控制器的XCode iPad项目。我试图获得一个按钮将UISplitViewController推送到导航堆栈,但是出现了这个错误:

I have an XCode iPad project using a navigation controller. I tried to get a button to push a UISplitViewController to the navigation stack, but got this error:


拆分视图控制器无法推送到导航控制器

Split View Controllers cannot be pushed to a Navigation Controller

结果显示UISplitViewController与UINavigationController不能很好地配合使用。但是,单击此按钮时,我仍需要显示拆分视图控制器。我该怎么做呢?而且,同样重要的是,如何制作一个后退按钮,以便用户可以返回导航控制器?

Turns out UISplitViewController doesn't play nicely with UINavigationController. However, I still need to show the split view controller when this button is clicked. How do I do this? And, also important, how do I make a back button so the user can be returned to the navigation controller?

推荐答案

显示一个SplitViewController你需要使用setRootViewController。这是因为SplitViewController需要是根视图控制器。

To display a SplitViewController you'll need to use setRootViewController. This is because a SplitViewController needs to be the root view controller.

来自Apple的文档:

From Apple's Documentation:


拆分视图控制器必须始终是
创建的任何接口的根。换句话说,您必须始终从
UISplitViewController对象安装视图作为应用程序的
窗口的根视图。然后,拆分视图界面的窗格可能包含
导航控制器,标签栏控制器或实现界面所需的任何其他类型的视图
控制器。

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application's window. The panes of your split-view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface.

要回来,你需要使用setRootViewController返回前一页。当我将我的iPhone应用程序转换为通用时,我遇到了这个问题,最终使用iPhone的导航控制器和iPad版的setRootViewController。这有点令人失望,因为你不能很好地动画它没有一点点捏造

To get back you'll need to use setRootViewController to go back to the earlier page. I ran into this problem when I converted my iPhone app to universal, and ended up using a navigation controller for the iPhone and setRootViewController for the iPad version. It's a bit of a bummer because you can't animate it nicely without a bit of fudging.

这篇关于iOS:无法将UISplitViewController推送到UINavigationController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆