首先说一下为什么用陀螺仪,很多时候当ios设备系统级别锁定方向后,我们使用ios系统的设备方向方法将不能其作用。 ios系统代码中为一下代码:
//下面代码只有在设备系统不锁定屏幕旋转是Natifications 方法才起作用。
- (void) addDeviceRotateObserver {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(rotateViews:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
- (void) rotateViews:(NSObject *)sender {
UIDevice* device = [sender valueForKey:@"object"];
NSLog(@"%d",device.orientation);
// switch (device.orientation) {
// case UIDeviceOrientationPortrait: {
// NSLog(@"P");
// break;
// }
// case UIDeviceOrientationLandscapeLeft: {
// NSLog(@"LL");
本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕,E-mail:xinmeigg88@163.com
本文链接:http://www.xrbh.cn/tnews/8955.html