Layout

Size from the window, not the screen

Replace UIScreen.main, orientation checks, idiom checks, and hard-coded device dimensions so your iOS app resizes cleanly when iPhone Duo folds and unfolds.

7 min readUpdated 3 sources

Folding or unfolding iPhone Duo doesn’t relaunch your app. The scene stays connected and your process keeps running while the system resizes your window and updates its traits. Any code that caches the screen size at launch — or infers layout from hardware identity — will keep using stale dimensions, leading to stretched, clipped, or misplaced views.2

Start by searching your project for the five patterns below.

1. UIScreen.main

On a phone with two displays, “the main screen” has no clear meaning, and Apple plans to deprecate UIScreen.main in a future SDK release.12

Instead of Use
UIScreen.main.bounds view.bounds or window.bounds; in SwiftUI, GeometryReader or onGeometryChange
UIScreen.main.scale traitCollection.displayScale; in SwiftUI, @Environment(\.displayScale)
UIWindow(frame: UIScreen.main.bounds) UIWindow(windowScene:)
A stored UIScreen reference view.window?.windowScene?.screen, read on demand
func updateThumbnail(from image: UIImage) {
    // Before
    let screenScale = UIScreen.main.scale

    // After
    let screenScale = traitCollection.displayScale
    // ...
}

2. Reading the size only once

Reading dimensions at launch or in viewIsAppearing isn’t enough when unfolding the phone can resize your window mid-session.2 Move size-dependent layout into callbacks that fire on every resize:

  • layoutSubviews or viewDidLayoutSubviews for view positioning.
  • viewWillTransition(to:with:) for transitions that need coordinator animations or collection view layout invalidation.

In SwiftUI, onGeometryChange lets you react to size changes without wrapping your view hierarchy in a GeometryReader.

3. Orientation as a layout signal

On iPhone Duo, device orientation no longer tells you your window’s aspect ratio. The inner display ignores UISupportedInterfaceOrientations, and a landscape device in Split View can host a tall, narrow app window.1 Remove layout logic that branches on:

  • UIDevice.current.orientation
  • statusBarOrientation
  • interfaceOrientation, including windowScene.effectiveGeometry.interfaceOrientation

If you need to know whether your canvas is wider than it is tall, compare the bounds you actually have:

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    let isWide = view.bounds.width > view.bounds.height
    // Update layout here
}

Inside a custom view, check superview.bounds; in SwiftUI, compare the size reported by GeometryReader or onGeometryChange.

Orientation locks still apply on the outer display, which respects UISupportedInterfaceOrientations like a standard iPhone. Even so, a portrait-locked app will receive both compact and regular size classes on the inner display and in Split View, so its layout still needs to adapt.3

4. Idiom checks

Search your codebase for userInterfaceIdiom == .phone and == .pad. Between iPhone Duo and resizable iPhone Mirroring on macOS, an iPhone app can now encounter any combination of size classes. Code that unlocks a multi-column layout when horizontalSizeClass == .regular — or assumes .phone is always compact — will trigger on iPhone Duo. Drive layout decisions from size classes or available width rather than userInterfaceIdiom.2 See Size classes, safe areas and standard containers.

5. Hard-coded device dimensions

Checks like bounds.height == 844 or lookup tables of known iPhone screen sizes will fail on iPhone Duo and its Split View configurations. Replace them with adaptive constraints or size-class checks.

Bonus: full-bleed media

Hero images and video players using .scaleAspectFill or .aspectRatio(contentMode: .fill) can crop out key subjects on the wider 7.6-inch inner display. Switch between fill and fit based on the current aspect ratio, or anchor cropping around a focal point.1

If you maintain frame-based layout code

Apple recommends Auto Layout (translatesAutoresizingMaskIntoConstraints = false) over manual frame calculations. Where manual frames are unavoidable, compute them from view.bounds and safeAreaInsets inside viewDidLayoutSubviews — never from cached startup values.3

UIRequiresFullScreen is not an escape hatch

iPhone Duo still respects UIRequiresFullScreen to opt out of Split View, but your app will still resize whenever the user opens or closes the phone. Apple has deprecated the key (see TN3192 for migration guidance) and recommends removing it as soon as possible.3

Sources

  1. Apple Developer: Prepare your app for iPhone Duo (Step 2: Fix patterns)
  2. Tech Talk: Prepare your app for iPhone Duo (Avoid screen assumptions)
  3. Apple Developer Forums: A summary of the iPhone Duo Group Lab