【发布时间】:2016-03-14 09:02:32
【问题描述】:
应用程序进入后台后,我需要获取设备方向(纵向、倒置、横向、横向),然后通过蓝牙将其发送到另一台设备。 [UIDevice currentDevice].orientation 在后台模式下不起作用。有什么办法可以做到吗?
【问题讨论】:
标签: iphone background orientation
应用程序进入后台后,我需要获取设备方向(纵向、倒置、横向、横向),然后通过蓝牙将其发送到另一台设备。 [UIDevice currentDevice].orientation 在后台模式下不起作用。有什么办法可以做到吗?
【问题讨论】:
标签: iphone background orientation
有一个名为-[UIApplication _getSpringBoardOrientation] 的私有方法,它只是调用另一个私有方法-[UIApplication activeInterfaceOrientation],这似乎为您提供了当前前台应用程序的方向。
但据我所知,我认为它不会捕获背景中的方向变化,因为 UIDevice 类不能那样工作。但是,当您的应用程序进入后台时,您可以使用
捕获最后的方向状态Objective-C
-(void)applicationDidEnterBackground:(UIApplication *)application
Swift
func applicationDidEnterBackground(application: UIApplication)
【讨论】: