ios强制横/竖屏

- (void)viewWillAppear:(BOOL)animated {

    NSNumber *orientationUnknown = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];

    [[UIDevice currentDevice] setValue:orientationUnknown forKey:@"orientation"];


    NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];

    [[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];

}

- (BOOL)shouldAutorotate {

    return YES;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    return UIInterfaceOrientationLandscapeLeft;

}

你可能感兴趣的:(ios强制横/竖屏)