特定的界面支持横竖屏(可以modal或者push)

-(void)forceToOriention:(UIInterfaceOrientation)direction

{

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

        [invocation setArgument:&val atIndex:2];

        [invocation invoke];

    }

    

}

- (void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

     [self forceToOriention:UIInterfaceOrientationLandscapeRight];

}

- (void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];

    [self forceToOriention:UIInterfaceOrientationPortrait];

 

}

posted @ 2016-06-24 16:08  YuFly  阅读(153)  评论(0编辑  收藏  举报