/**

 强制旋转屏幕为纵向 (注:这种方式 键盘不能旋转过来; iOS8.x UIAlterView旋转不过来  )

 @return

 */

+ (void)rotateOrientationPortrait{

    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 = UIInterfaceOrientationPortrait;

        [invocation setArgument:&val atIndex:2];

        [invocation invoke];

    }

}

/**

 强制旋转屏幕为横向,Home建向右 (注:这种方式 键盘不能旋转过来; iOS8.x UIAlterView旋转不过来  )

 @return

 */

+ (void)rotateOrientationLandscapeRight{

    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 = UIInterfaceOrientationLandscapeRight;

        [invocation setArgument:&val atIndex:2];

        [invocation invoke];

    }

}

posted on 2016-05-26 14:54  爱拼  阅读(1527)  评论(0编辑  收藏  举报