Xcode9 2018年最新关于app编写中,大部分界面强制竖屏

2018-03-20  本文已影响0人  灰客

第一步:


8180BBD0-9D78-4110-980A-F1D0F2651D27.png

第二步:
在AppDelegate里面添加方法2个

{

UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;

UIViewController *topVC = appRootVC;

if (topVC.presentedViewController) {
    
    topVC = topVC.presentedViewController;
    
}

return topVC;

}

//锁定用户手机APP为竖屏模式

}

第三步:
具体需要横屏的控制器添加下面方法

pragma mark 强制横屏(针对present方式)

//必须有
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}

第四步:
在竖屏A prensent到横屏B中,所有A都要添加代码
//强制转屏

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];

[self interfaceOrientation:UIInterfaceOrientationPortrait];

}

感谢兄弟技术支持:请输入账号名

灰客原创,转帖请注明出处,希望有大神能斧正!

上一篇 下一篇

猜你喜欢

热点阅读