iPad UISplitViewController幻像主视图控制器 [英] iPad UISplitViewController Phantom Master View Controller

查看:290
本文介绍了iPad UISplitViewController幻像主视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用UISplitViewController寻找自动旋转问题的解决方案。重新创建的步骤是:

Looking for a solution to an autorotation issue using UISplitViewController. The steps to re-create are:


  1. 使用Xcode 4.5+和iOS6 + SDK,使用Master-Detail Application创建一个新项目:template。

  2. 使用全屏大小的XIB文件向项目中添加一个新的视图控制器。

  3. 在细节上添加一个按钮视图控制器使用-presentViewController呈现新视图控制器全屏:动画:完成:

  4. 向新视图控制器添加一个按钮,使用dismissViewControllerAnimated解除自身:完成:

  5. 使用横向模式的iPad启动应用程序,然后点击显示新视图控制器的详细信息视图中步骤3中创建的按钮。

  6. 查看完整视图时屏幕视图控制器,将iPad旋转为纵向,然后点击步骤4中添加的按钮以关闭新的视图控制器。

  1. Using Xcode 4.5+ and the iOS6+ SDK, create a new project using the "Master-Detail Application: template.
  2. Add a new view controller to the project with a XIB file that is full screen in size.
  3. Add a button to the detail view controller that presents the new view controller full screen using -presentViewController:animated:completion:
  4. Add a button to the new view controller that dismisses the itself using dismissViewControllerAnimated:completion:
  5. Start the app with the iPad in landscape mode and hit the button created in step 3 in the detail view that presents the new view controller.
  6. While viewing the full screen view controller, rotate the iPad to portrait and then tap the button added in step 4 to dismiss the new view controller.

问题:使用这些步骤,主视图和详细视图控制器都将自动运行但是主视图控制器将保持在屏幕上处于无响应状态,并占据屏幕左上角的框架,该框架与横向模式下的框架大小相同。通过使用iPad左侧的手势,将显示正确的主视图控制器并清除问题。

THE PROBLEM: Using these steps, both the master and detail view controller will auto-rotate but the master view controller will stay on the screen in an unresponsive state and taking up a frame in the upper left of the screen that is the same size as it was in landscape mode. By using a gesture from the left side of the iPad, the correct master view controller will be displayed and the issue is cleared.

我们已经能够使用viewWillAppear和viewDidDisappear在新的视图控制器中隐藏幻像主视图控制器,但即使使用该修复,模板提供的主按钮在执行上述步骤后仍然无响应,我们已将其跟踪到该区域的事实在修复之前由主视图控制器占用的左上角屏幕没有响应触摸。

We have been able to use viewWillAppear and viewDidDisappear in the new view controller to make the phantom master view controller hide, but even with that fix, the "Master" button that the template provides in portrait remains unresponsive after following the above steps, and we have traced it to the fact that the region of the screen in the upper left taken up by the master view controller prior to the fix is unresponsive to touch.

我们尝试了几次尝试将第一个响应者辞职不同的方式,但没有完全解决问题的运气。

We have tried a few attempts at resigning the first responder in different ways but have had no luck completely fixing the issue.

注意:如果遵循上述步骤5-6,通常会发生此问题首次启动应用程序时。在单个应用程序启动中重复步骤6通常不会每次都导致问题。它在应用程序的每次启动时都是可重复的。

NOTE: This issue only usually happens if the above Steps 5-6 are followed when first launching the app. Repeating step 6 within a single app launch usually does not result in the issue every time. It is repeatable on every launch of the app.

推荐答案

找到了解决此问题的方法。

Found a fix for this.


  1. 在调用presentViewController之前,将视图控制器的模态演示样式设置为UIModalPresentationPageSheet:animated:completion:。

  2. 然后,做了覆盖视图控制器-viewWillLayoutSubviews方法,手动设置超级视图的边界以匹配屏幕大小,肖像为768x1004,横向为1024x748。

这篇关于iPad UISplitViewController幻像主视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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