Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iPad iOS 9+;什么时候锁在外面?_Ios_Objective C_Ipad_Ios9 - Fatal编程技术网

如何在iPad iOS 9+;什么时候锁在外面?

如何在iPad iOS 9+;什么时候锁在外面?,ios,objective-c,ipad,ios9,Ios,Objective C,Ipad,Ios9,在iPad ios 9+上,使用objective-c: -锁定应用程序外部的方向 -在代码中:如何检测设备何时改变方向 我已经尝试了所有的可能性: 1) 尝试捕获UIDeviceOrientationIDChangeNotification事件: - (void)subscribeOrientationChangeEvent { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

在iPad ios 9+上,使用objective-c: -锁定应用程序外部的方向 -在代码中:如何检测设备何时改变方向

我已经尝试了所有的可能性:

1) 尝试捕获UIDeviceOrientationIDChangeNotification事件:

- (void)subscribeOrientationChangeEvent { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]]; } - (void) orientationChanged:(NSNotification *)note { NSLog("Device rotated"); } -(作废)SubscribeOrientionChangeEvent{ [[UIDevice currentDevice]BegingeratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter]添加观察者:self 选择器:@selector(方向更改:) 名称:UIDeviceOrientationIDChangeNotification 对象:[UIDevice currentDevice]]; } -(无效)方向更改:(NSNotification*)注{ NSLog(“设备旋转”); } 2) 重写ViewWillTransitionOnSize方法

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; NSLog("Device rotated"); } -(void)ViewWillTransitionOnSize:(CGSize)带有TransitionCoordinator:(id)coordinator的大小 { [super ViewWillTransitionSize:size with TransitionCoordinator:coordinator]; NSLog(“设备旋转”); } 3) 使用KVO查看[UIDevice CurrentDevice]

4) 使用KVO查看[UIApplication sharedApplication]的值是否为statusBarOrientation

5) 设置需要全屏显示设置StatusBarStyle

参考:

应用此设置并与上述所有尝试结合,但均失败

6) 使用加速计(CMMotionManager)
有什么建议吗?如果设备方向是锁定的,非常感谢

;你的应用程序必须遵守它。由于明显的原因,您将无法检测方向。所以简单的回答是你不能

如果设备方向为锁定;你的应用程序必须遵守它。由于明显的原因,您将无法检测方向。所以简单的回答是你不能

尝试检测设备何时从锁定状态返回,然后检查是否有新的方向。这不是我的目的。尝试检测设备何时从锁定状态返回,然后检查是否有新的方向。这不是我的目的。在iOS 10+中,即使用户在外部锁定,也可以使用ViewWillTransitionOnSize检测方向事件。甚至,在iPhone上的iOS 9+中,您可以使用ViewWillTransitionOnSize进行检测。但是,仅在iPad ios 9上是不可能的。在ios 10+中,即使用户锁定在外部,您也可以使用ViewWillTransitionoSize来检测方向事件。甚至在iPhone上的ios 9+中,您也可以使用ViewWillTransitionoSize来检测。然而,只有在iPadiOS9上,这是不可能的。