【问题标题】:My iOS 8.0 application is not rotating, and I have no idea why. How can I debug device rotation?我的 iOS 8.0 应用程序没有旋转,我不知道为什么。如何调试设备旋转?
【发布时间】:2015-06-06 20:39:13
【问题描述】:

我正在构建一个应用程序,其界面在设备旋转正常时始终旋转得很好,但现在根本不旋转。

最奇怪的是,应用程序在模拟器中运行时旋转得很好。这告诉我,我的应用程序代码绝对没有问题。

我的项目设置明确声明支持所有方向:

这可能是什么问题?我应该怎么做才能找出自上次工作和轮换以来发生了什么变化?谢谢。

编辑:响应 cmets,是的,我确定设备的方向没有被锁定(即从命令窗格),并且硬件开关与方向没有任何关系。 Springboard 和其他应用可以很好地旋转。

【问题讨论】:

  • 您是否在您的 ViewControllers 中为 supportedInterfaceOrientations 指定了任何内容?
  • 您确定设备没有被锁定?其他应用程序会轮换吗?
  • 感谢您的 cmets,我已根据您的查询更新了我的问题。
  • 哇,这很奇怪。我刚刚再次运行了我的应用程序的开发版本,没有任何更改,它可以工作。
  • 可能是 Xcode 著名的clean,可能删除派生数据,它神奇地起作用了!

标签: ios screen-rotation


【解决方案1】:

尝试实现这个:

对于 iOS 2.0 - 7.1.2,使用以下 UIView 委托方法:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    // Print a message to the screen to make sure its being called
    NSLog(@"Trying to rotate...");
}

对于 iOS 8 及更高版本:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{   
    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
    {
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

        // Write to log
        NSLog(@"Trying to change view...");

    } completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
    { 

    }];

    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

这应该有助于查看设备是否正在尝试旋转...

【讨论】:

    猜你喜欢
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-03
    相关资源
    最近更新 更多