How can I lock orientation only on IPhone
Detect the device is iPhone
if UIDevice().userInterfaceIdiom == .phone {
switch UIScreen.main.nativeBounds.height {
case 1136:
print("iPhone 5,5S,5C")
case 1334:
print("iPhone 6,6S,7,8")
case 2208:
print("iPhone 6+,6S+,7+,8+")
case 2436:
print("iPhone X")
default:
print("unknown")
}
}
I use this code but he is lock orientation on iPhone and on iPad
In ViewDidLoad:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask(rawValue: UIInterfaceOrientationMask.portrait.rawValue)
}