我有一个使用导航控制器的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!