บางกรณีต้องการให้ UI แสดงใน Orientation เฉพาะ เช่น Portrait หรือ Landscape เท่านั้น
วิธีล็อก Orientation ด้วยโปรแกรมใน Swift:
ใน ViewController.swift ใส่โค้ด:
// ปิด Auto Rotate
override open var shouldAutorotate: Bool {
return false
}
// ระบุ Orientation ที่รองรับ
override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
