在info.plist中找到“Supported interface orientations”,去掉“Portait(bottom home button)”和“Landscape(left home button)”,留下“Landscape(right home button)”。
在viewDidLoad()中添加UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
重载overridevarshouldAutorotate:Bool{
return false
},将返回值设为false。
通过以上步骤就可以了。