APP设置里面,必定要设置能够旋转的方向app
appdelegate里面从新系统方向代理ide
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {spa
return UIInterfaceOrientationMask.Portrait // 设置所有为竖屏代理
}blog
在想要实现横屏的controller里面重写it
是否支持自动横屏,io
override func shouldAutorotate() -> Bool {class
return false方法
}im
支持的方向
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Landscape // 表明横屏,左右横屏
}
物理显示屏幕,即将显示屏幕方向
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.LandscapeLeft
}
若是此controller含nav,应该在nav里面重写这个方法,controller不须要写