【问题标题】:Device Orientation Incorrect When Notification Banner Appears出现通知横幅时设备方向不正确
【发布时间】:2015-08-26 14:02:53
【问题描述】:

我有一个应用程序正在监视UIDevice 的“方向”属性。一切都很好,除了每当出现推送通知或 SMS(任何触发横幅通知出现在应用上方的东西)时,UIDevice 类都会报告 UIDeviceOrientationPortrait

这感觉像是一个错误,但我不确定其他人是否已经看到或知道这是预期的。

【问题讨论】:

  • 你能澄清一下,你的问题吗?
  • 即使我将设备正面朝下,但如果收到通知,例如短信或电子邮件,[UIDevice currentDevice].orientation 开始报告 UIDeviceOrientationPortrait,这是错误的。
  • 您能否在您的 appdelegate.m 中确认supportedInterfaceOrientationsForWindow 方法的返回值。对于所有方向支持,它必须返回UIInterfaceOrientationMaskAll

标签: ios objective-c notifications uidevice


【解决方案1】:

通过将以下方法添加到您的 AppDelegate.m 类中,您的应用必须能够支持所有类型的设备方向。

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll; 
}

您还可以检查所有设备方向,如图所示

祝你好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多