ios强制横/竖屏

2018-07-10  本文已影响0人  zttjhm

- (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;

}

上一篇 下一篇

猜你喜欢

热点阅读