在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
? ? },將返回值設(shè)為false晶伦。
通過以上步驟就可以了聪黎。