Skip to content
iPhone Duo SupportGet help

Remove hard-coded screen dimensions and fixed frame widths

Blockerlayout

What you see

Content is stuck in a narrow column on the left, stretched past the edges, or overlapping after the device is unfolded.

This is the single most common cause of broken layout on iPhone Duo, and it is worth auditing before anything else on this list.

Why it happens

Every iPhone before iPhone Duo was between roughly 320 and 440 points wide. That made a hard-coded width look safe for years. The inner display is 626 × 890 points, so any constant tuned for a 402-point iPhone 18 Pro is now off by more than 200 points.

Worse, the width now changes at runtime. The device folds, unfolds, rotates, and enters Split View multitasking, and your app moves between two physically different displays. A width captured once at launch is wrong within seconds of the user opening the device.

Find it

Search your project for the patterns that bake in a width:

grep -rn "UIScreen.main.bounds" --include="*.swift" .
grep -rn "\.frame(width:" --include="*.swift" .
grep -rn "widthAnchor.constraint(equalToConstant:" --include="*.swift" .

Not every hit is a bug. A 44-point button is fine. What matters is anything sized as a proportion of, or a stand-in for, the screen.

The fix

Let the layout system supply the size rather than asserting it.

// Before — a constant that was only ever right on one device class
content.frame(width: 390)

// After — fill the space you are given, with a readable upper bound
content
    .frame(maxWidth: .infinity)
    .frame(maxWidth: 700)   // cap line length, don't pin to a device

In UIKit, prefer relative constraints over constants:

// Before
view.widthAnchor.constraint(equalToConstant: 390).isActive = true

// After
NSLayoutConstraint.activate([
    content.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
    content.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
    content.widthAnchor.constraint(lessThanOrEqualToConstant: 700),
])

When you genuinely need the current size, read it reactively so it updates as the device folds:

GeometryReader { proxy in
    GalleryView(columns: proxy.size.width > 600 ? 3 : 1)
}

Apple’s framing is to design across a continuum of sizes rather than for a set of known devices. A layout built that way needs no changes when the next form factor ships.

How to verify

Run in the iPhone Duo simulator via Device Hub in Xcode 27.1 and use the on-screen controls to open, close, fold, and rotate while watching the layout. Anything that jumps, clips, or leaves a large empty band is a hard-coded value you have not found yet.

← All checksGet help with this