[英]How can I detect if UI orientation is locked or not on iOS?
Is it possible to detect UI orientation is locked or not currently?是否可以检测到当前 UI 方向是否已锁定? If so, how can I do that?如果是这样,我该怎么做?
I want to do something with gravity sensor when only UI orientation is not locked.当只有 UI 方向未锁定时,我想用重力传感器做一些事情。
Not possible unfortunately, the lock is handled by the OS and is transparent to the app.不幸的是,锁是由操作系统处理的,对应用程序是透明的,这是不可能的。
Why not try calling the shouldAutorotate method and see what BOOL value is returned?为什么不尝试调用 shouldAutorotate 方法并查看返回的 BOOL 值?
I haven't tried looking for the UIOrientation lock.我还没有尝试寻找 UIOrientation 锁。 But off the top of my head, this is how I'd try.但在我的脑海中,这就是我会尝试的方式。
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft])
NSLog(@"Rotates LandscapeLeft");
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight])
NSLog(@"Rotates LandscapeRight");
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait])
NSLog(@"Rotates Portrait");
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown])
NSLog(@"Rotates PortraitUpsideDown");
Hopefully this solves your problem.希望这可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.