iOS开发中,代码如何判断 “竖排方向锁定” 是否开启?

解决方案 »

  1.   

    试试把设备固定为竖屏
    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
            SEL selector = NSSelectorFromString(@"setOrientation:");
            NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
            [invocation setSelector:selector];
            [invocation setTarget:[UIDevice currentDevice]];
            int val = UIDeviceOrientationPortrait;
            [invocation setArgument:&val atIndex:2];
            [invocation invoke];
        }
        [UIViewController attemptRotationToDeviceOrientation];
      

  2.   

    如果想自己控制的横竖屏的话看这里http://blog.csdn.net/codingfire/article/details/50387774完全自己掌握横竖屏
      

  3.   

    据说:当lock或者unlock时,-[UIViewController shouldRotateToInterfaceOrientation:] 都会被调用,你试试。