【问题标题】:rotation change not triggered anymore不再触发旋转更改
【发布时间】: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


【解决方案1】:

你可以使用

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window in Appdelegate

【讨论】:

  • 我想调用我的mentoined 方法,因为它已经很好用了。有什么提示吗?
  • 我发现了问题,很抱歉浪费您的时间。我更新了问题
【解决方案2】:

对不起,伙计们。这对我来说是一个愚蠢的失败。我有一个父 uiviewcontroller 实现了 viewWillTransitionToSize 并忘记调用超级,所以它也会识别我的子视图中的旋转。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    相关资源
    最近更新 更多