I think you have to do it programmatically (at least, I had to).
I did it this way (after some try and error):
// 1. Define an enum Credit https://stackoverflow.com/questions/29528661/ ios-detect-current-size-classes-on-viewdidload
enum DeviceTraitStatus {
// IPAD and others: Width: Regular, Height: Regular
case wR
case wC
case hR
case hC
case wRhR
// Any IPHONE Portrait Width: Compact, Height: Regular
case wChR
// IPHONE Plus/Max Landscape Width: Regular, Height: Compact
case wRhC
// IPHONE landscape Width: Compact, Height: Compact
case wChC
static var current:DeviceTraitStatus {
switch (UIScreen.main.traitCollection.horizontalSizeClass, UIScreen.main.traitCollection.verticalSizeClass){
case (UIUserInterfaceSizeClass.regular, UIUserInterfaceSizeClass.unspecified):
return .wR
case (UIUserInterfaceSizeClass.compact, UIUserInterfaceSizeClass.unspecified):
return .wC
case (UIUserInterfaceSizeClass.unspecified, UIUserInterfaceSizeClass.regular):
return .hR
case (UIUserInterfaceSizeClass.unspecified, UIUserInterfaceSizeClass.compact):
return .hC
case (UIUserInterfaceSizeClass.regular, UIUserInterfaceSizeClass.regular):
return .wRhR
case (UIUserInterfaceSizeClass.compact, UIUserInterfaceSizeClass.regular):
return .wChR
case (UIUserInterfaceSizeClass.regular, UIUserInterfaceSizeClass.compact):
return .wRhC
case (UIUserInterfaceSizeClass.compact, UIUserInterfaceSizeClass.compact):
return .wChC
default:
return .wChR
}
}
}
// 2. Get device status
let dts = DeviceTraitStatus.current
// 3. Get screenSize
let wScreen = UIScreen.main.bounds.size.width
var hScreen = UIScreen.main.bounds.size.height
// 4. Then test for all possible height regular, and find if iPad :
if dts == .wRhR || dts == .wChR || dts == .hR {
if wScreen >= 400 && hScreen >= 768 { // Do what you need to adjust constraints IBOutlets
}
}
// 5. Then test for all possible height compact, and find if iPad :
if dts == .wRhC || dts == .wChC || dts == .hC {
if hScreen >= 540 && wScreen >= 1000 { { // Do what you need to adjust constraints IBOutlets
}
}
You will have to check precisely the sizes (see here: https://www.ios-resolution.com/), for instance:
// 12ProMax
// Portrait wChR h 879.0 w 428.0
// Landscape wRhC h 428.0 w 926.0
// 12Pro
// Portrait wChR h 797.0 w 390.0
// Landscape wChC h 390.0 w 844.0