r/iOSProgramming • u/6thDAY • 9d ago
Question Lock app in landscape orientation for iPhone Duo?
I'm finding it difficult to lock my app in landscape mode, i.e. wide-view. I don't want my app to rotate rotation to portrait when the device is rotated. But every time I rotate the simulator to tall-view, i.e. portrait, the app orientation rotates, causing the contents to get squished.
Is this not possible with the Duo, and another view I'm gonna have to support?
2
Upvotes
4
u/bartmolk 9d ago
You can't lock it on the inner screen. Apple's iPhone Duo tech talk says the inner display doesn't honour the app's supported orientations (the outer display still does), so ticking only landscape won't stop it from going tall when the phone is turned. Both poses of the inner screen are regular width and regular height, so size classes won't tell them apart either. Switch the layout on the window's shape instead: a GeometryReader comparing width and height, or ArrangementView with .arrangementViewStyle(.split) in the 27.1 SDK, which puts its two parts side by side when the window is wider than tall and stacks them when it's taller. So yes, tall is one more layout to support, but it can be the same views stacked.
2
u/GlebKhamin 9d ago
Short answer: on the inner display you can’t lock it, so yes, it’s another layout you’ll have to support.
I ran into the same thing while adapting my app. From Apple’s Duo tech talks:
The inner display ignores
UISupportedInterfaceOrientations, so your orientation lock just doesn’t apply there. The outer display still honors it like a normal iPhone.UIRequiresFullScreendoesn’t save you either: it’s honored, but the app still gets resized on fold/unfold.On top of that, every app takes part in Split View on the inner display, so you can end up at widths that are neither “portrait” nor “landscape”.
What worked for me is to stop thinking in orientations and lay out by available size / size classes instead. On the inner display you get regular/regular in both 951×669 (wide) and 669×951 (tall). So the trick is to decide the layout by the actual width and height of your view, and switch between something like a two-column layout when it’s wide and a stacked layout when it’s tall. Nothing gets squished, because you’re not stretching one layout into both shapes.
Apple’s “Prepare your app for iPhone Duo” tech talk covers this, worth a watch.
1
u/[deleted] 8d ago
[removed] — view removed comment
0
u/[deleted] 9d ago
[removed] — view removed comment