Group Group Group Group Group Group Group Group Group

Landscape View iPhone 11 Pro Max

In Chapter 47 for the section Landscape on iPhone Plus you don’t handle the case for iPhone X’s I am curious as to how you would go about this. I know this question has been asked before (in 2018) and it was said that would be updated in a newer version. I’m currently using the newer version and don’t see anything mentioning iPhone X models.

Also, I don’t understand how the logic works on knowing when to present a split view in the landscape for the iPhone 8 plus devices. Currently, your switch statement in willTransition is this

let rect = UIScreen.main.bounds
    if (rect.width == 736 && rect.height == 414) || (rect.width == 414 && rect.height == 736) {
        if presentedViewController != nil {
            dismiss(animated: true, completion: nil)
    } else if UIDevice.current.userInterfaceIdiom != .pad {
        switch newCollection.verticalSizeClass {
        case .compact:
            showLandscape(with: coordinator)
        case .regular, .unspecified:
            hideLandscape(with: coordinator)
        @unknown default:

All this does is check if a pop-over is displayed and then dismisses it if one is visible. If the first if condition checks out, it never goes to the else if using a plus device. So how does it know to show a split view controller?

Also, willTransition doesn’t even get called when turning over the iPad device to present the landscape view.

@mcneils Do you still have issues with this?

yes I am still having issues with this.

@ganem Can you please help with this when you get a chance? Thank you - much appreciated! :]

Thanks for your patience @mcneils.
We’re using a UISplitViewController which, according to the documentation, decides whether to show the view controllers side-by-side:

The split view controller determines the arrangement of its child view controllers based on the available space. In a horizontally regular environment, the split view controller presents its view controllers side-by-side whenever possible. In a horizontally compact environment, the split view controller acts more like a navigation controller, displaying the primary view controller initially and pushing or popping the secondary view controller as needed. You can also ask the split view controller to prefer a specific arrangement by assigning a value to the preferredDisplayMode property.

For some reason, iPhone 8 Plus is considered wide enough when in landscape mode (with 736 pixels), while the iPhone X isn’t (although it has 812 pixels). Not sure why it’s like that, but that’s how Apple defined the sizes.

So unfortunately this isn’t “fixable”, although according to Apple guidelines it isn’t even broken :slight_smile:

As for the willTransition code - since we know that for devices with dimensions 736x414 UISplitViewController will present the view controllers side-by-side, there’s no need to change the view controller that us displayed. That’s why we just dismiss any VC if there is any instead of calling the relevant showLandscape or hideLandscape methods.

This topic was automatically closed after 166 days. New replies are no longer allowed.