通常我们的App是不能横屏的,只在播放视频时可以横屏,所以我们就要对App禁止横屏。
这里讨论全局禁止横屏的两种方法,暂不讨论特定页面横屏问题。
1.APP Target
APP Target -> General -> Deployment Info -> 取消勾选 Landscape Left 和 Landscape Right。
2.AppDelegate.m
在AppDelegate.m加上下面的代码,当App需要横屏只需修改这段代码即可。
-(UIInterfaceOrientationMask)application:(UIApplication * )application
supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}