UISplitViewController - willShowViewController 未触发
我正在将 iPhone 应用程序转换为在 iPad 上运行。在本例中,用户界面是使用界面生成器创建的。根控制器的界面(索引 0)由选项卡控制器和选项卡控制器组成。此布局中的导航控制器:
- 选项卡控制器
- 导航控制器 1
- 导航控制器 2
- 导航控制器 3
我一直在分段实现此功能。当我设置选项卡控制器和导航控制器 1 作为第一步,一切正常。 willHideViewController & willShowViewController 正常工作。我的界面正确地从 SplitView 切换到 Popover。当我添加导航控制器 2 时, willHideViewController & willShowViewController 永远不会触发 &无论 iPad 在模拟器中的方向如何,我总是能看到 Popover 控制器。
当我添加第二个导航控制器时,是否需要在界面生成器中绑定其他内容才能使界面正常工作?
I am converting an iPhone application to work on the iPad. In this case, the user interface was created with interface builder. The interface of the root controller (at index 0), consists of a Tab Controller & Navigation Controllers in this layout:
- Tab Controller
- Navigation Controller 1
- Navigation Controller 2
- Navigation Controller 3
I have been implementing this in pieces. When I setup the Tab Controller & Navigation Controller 1 as a first step, everything works correctly. willHideViewController & willShowViewController work correctly. My interface switches from SplitView to Popover correctly. When I add Navigation Controller 2, willHideViewController & willShowViewController never fire & I always see the Popover controller no matter what orientation the iPad is within the simulator.
When I add a second navigation controller, is there something else I need to tie off within the interface builder to get the interface to work correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜您已经为第一个导航控制器设置了委托,但没有为第二个导航控制器设置了委托。委托对象将接收像 willHideViewController 这样的方法。
我也不确定拥有多个导航控制器是一种好的风格。视图控制器知道它已被放置在导航控制器中,并且您可以使用 self.navigationController 访问它。您应该继续将视图控制器推送到同一个导航控制器上。或者我可能误解了您尝试使用选项卡控制器执行的操作。
I'm guessing that you've set a delegate for the first navigation controller but not one for the second. The delegate object would receive methods like willHideViewController.
I'm also not sure that having multiple navigation controllers is good style. A view controller knows that it has been placed in a navigation controller, and you can access this with self.navigationController. You should keep pushing view controllers on the same navigation controller. Or I may have misunderstood what you're trying to do with your tab controller.
答案非常简单:当您实现分割视图控制器时如果您希望所有内容都能正确地从纵向切换到横向,则需要确保所有界面元素都实现纵向和横向的 shouldAutorotateToInterfaceOrientation景观布局。
The answer to this is pretty simple: When you implement the split view controller & you want everything to switch correctly from portrait to landscape, you need to make sure that all the interface elements implement shouldAutorotateToInterfaceOrientation for portrait & landscape layouts.