Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> iOS

วิธีปิด Orientation Change ใน iOS (ล็อก Portrait/Landscape)

บางแอปทำงานแค่ Portrait หรือ Landscape ต้องล็อก Orientation

ล็อกด้วยโค้ด

ใต้ viewDidLoad:

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
get { return .portrait }
}

ล็อก Landscape: เปลี่ยน .portrait เป็น .landscape

ล็อกจาก Xcode Builder

Project Settings → Deployment Info → Device Orientation ติ๊กเฉพาะที่ต้องการ

วิธีปิด Orientation Change ใน iOS (ล็อก Portrait/Landscape)