【发布时间】:2016-01-29 10:23:36
【问题描述】:
我有一个带有视图控制器的应用程序。 我已经覆盖了以下方法:
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
override func willRotateToInterfaceOrientation(
toInterfaceOrientation: UIInterfaceOrientation,
duration: NSTimeInterval) {
override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
override func shouldAutorotate() -> Bool 未实现。
我正在将我的设备从纵向旋转到横向,但没有触发任何方法。我知道我的 viewWillTransitionToSize 是昨天触发的,但现在没有。我看不出可能是什么原因。
我没有看到关于旋转检测的任何变化。
有人有提示吗?
更新
对不起,伙计们。这对我来说是一个愚蠢的失败。 我有一个实现了 viewWillTransitionToSize 的父 uiviewcontroller,但忘记调用 super,所以它也会识别我的子视图中的旋转。
哦,我很抱歉浪费了大家的时间。 非常感谢。
【问题讨论】:
-
只添加这个,看看它是否有效:- [UIViewController attemptRotationToDeviceOrientation];
-
我在我的视图控制器中没有看到(语法错误)方法尝试旋转到设备方向。我试图在我的 viewdidappear 中添加 self.attemptRotationToDeviceOrientation(),这样正确吗?
-
是的...没错...现在检查!
-
我的 XCode 中出现语法错误“静态成员 'attemptRotationToDeviceOrientation' 不能用于类型为 'MyViewController' 的实例”
-
好的,我会的。谢谢
标签: ios swift orientation