My Classic splitviewcontroller app works as designed with regular iPhones and iPads. But because I add buttons (e.g. back buttons) that are often missing, when I test on the Plus size iPhones in the simulator (I don't have any of the mega phones), these buttons remain in iPhone plusses in landscape mode (like mini-iPads with the master and detail both showing). But I need to hide/remove those buttons in the detail view for the plus models.
So, how do I identify in code the mega iPhones that act like mini-iPads in landscape mode with splitviewcontrollers?
I used sizeClass information to detect it, as described in the link below.
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
}
}
}
The important case for you is:
case wChR
Get details here:
https://stackoverflow.com/questions/29528661/ios-detect-current-size-classes-on-viewdidload