objective-c - 当被模态视图 Controller 覆盖时,iOS 6 View Controller 布局在方向更改后不会更新

标签 objective-c ios ios6

我有一个 iPad 应用程序,非常适合 6 之前的 iOS 版本。

我的 Root View Controller 显示一个列表,当您单击列表中的任何项目时, Root View Controller 会呈现一个模态视图 Controller 来显示该项目的详细信息。

问题是,我的 Root View Controller 在横向和纵向上有不同的布局,当没有模态视图 Controller 存在时,当方向改变时它更新布局根本没有问题,但是当被模态视图 Controller 覆盖时,它不会更新,这只发生在 iOS 6 上。因此,当您单击某个项目时,模态视图 Controller 会覆盖整个屏幕,然后旋转设备,然后关闭模态视图 Controller ( Root View ) Controller 仍然是旧的方向布局,这真的很烦人。

我很清楚,在 iOS 6 中,shouldAutorotateToInterfaceOrientation 已被弃用,并且全屏模态视图 Controller 覆盖的任何 View Controller 都不会像在 6 之前的 iOS 中那样接收旋转事件。我按照本文中的建议进行了操作线程:iOS 6 Rotation issue - No rotation from Presented Modal View Controller ,这是手动将旋转事件从模态视图 Controller 传递到其后面的 View Controller ,但其后面的 View Controller 仍然不更新其布局。有什么解决办法吗?

最佳答案

将所有旋转逻辑移至viewDidLayoutSubviews。就这么简单,您将获得与以前相同的功能。将会发生的情况是,在您关闭模态视图 Controller 后,呈现的 View 将被布局,然后您可以切换到当前方向的适当布局。

关于objective-c - 当被模态视图 Controller 覆盖时,iOS 6 View Controller 布局在方向更改后不会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13325484/

相关文章:

objective-c - 我有什么方法可以检测我的应用程序是否已通过 Installous 下载?

iphone - 为什么即使我已经越狱,iOS 6.1.1中的SandBox对于App仍然存在?

ios - UIImageView+AFNetworking 图像未在 UITableViewCell 中正确加载

ios - iOS比较地理位置

javascript - 在 iOS 中使用 Javascript 构建一个简单的 WebView APP

ios - 如何判断指针指向的值何时为nil

iphone - 在 iPhone 编程中从字符串中获取数字

ios - 支持多种iOS-应用开发

animationControllerForPresentedController 和 animateTransition 之间的 iOS 未知延迟

javascript - 在 ios 6 上隐藏 safari 的地址栏