iOS:UISplitViewController 无法推送到 UINavigationControl

iOS: UISplitViewController cannot be pushed to UINavigationController(iOS:UISplitViewController 无法推送到 UINavigationController)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)