简体   繁体   English

屏幕旋转锁定时如何获取设备方向?

[英]How to get device orientation when the screen rotation is locked?

I used the notification to get the device's orientation.我使用通知来获取设备的方向。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [notificationCenter addObserver:self  
                                   selector:@selector(deviceOrientationDidChange)           
                                       name:UIDeviceOrientationDidChangeNotification 
                                     object:nil];

But the selector function is not called when the device's screen rotation is locked.但是当设备的屏幕旋转被锁定时,不会调用选择器函数。 Any help?有什么帮助吗?

You can use accelerometer to get values of screen orientation.您可以使用加速度计来获取屏幕方向的值。 See this .看到这个 Also see this blog另见博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 锁定iOS设备屏幕时,是否可以获得确切的时间? - Is it possible to get the exact time, when my iOS device screen is locked? 如果屏幕在纵向模式下被锁定,如何检测方向? - How to detect orientation, if screen is locked in portrait mode? 如何获得设备方向 - How to get device orientation 如何在应用程序部署信息纵向锁定时手动设置设备方向? - How to manually set the device orientation when App Deployment Info portrait is locked? UINavigationController工具栏和设备方向(旋转) - UINavigationController Toolbar and device orientation (rotation) 在设备旋转期间如何“锁定”视图的方向 - How to “lock” a view's orientation during device rotation iOS:在MPMoviePlayerController中将设备方向更改为“横向”时,如何全屏显示视频? - iOS : How to Full screen video when change device orientation to Landscape in MPMoviePlayerController? 当我的设备自动锁定时获取通知 - Get Notification when My device get auto locked 如何在 iOS 6 中以编程方式获取设备的当前方向? - How to get current orientation of device programmatically in iOS 6? 如何在 javascript 中获取 iPhone 7 的设备旋转? - How to get device rotation for iPhone 7 in javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM