Khóa ứng dụng chỉ chạy Portrait hoặc Landscape.
Cách 1: Code trong ViewController
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
get { return .portrait } // hoặc .landscape
}
Cách 2: Cài đặt trong Xcode Project
Target → General → Deployment Info → Device Orientation: bỏ tick Landscape (chỉ giữ Portrait) hoặc ngược lại.
Nếu không cấu hình, app chạy cả hai chế độ.