2

The new behavior

Ideally we'd have native iPad support, but that's a ways off and not feasible at the moment. So for now we have to work with iPad running the iPhone app. Hybrid Swift and Objective-C using UIKit, for context.

The app I'm working on has a camera view controller that, prior to iPadOS 15, would not rotate the field of view between portrait and landscape. However, with this new rotation behavior, the UI is shown in portrait when the iPad is in landscape. In the case of the camera, the field of view is now flipped 90º. The captured images are not flipped, but the sideways field of view isn't a good look.

What I've tried/observed so far is the following:

  • This new rotation behavior is not governed by the UIViewController's rotation methods. Overriding shouldAutorotate and supportedInterfaceOrientations does not prevent this rotation. So this is happening at the device level, and not the view controller level.

  • At the device level, I only know of one way to programmatically change orientation, using the private setter on UIDevice's orientation property. Obviously, private APIs are a no-no for the App Store, and a hack to leverage them may break in the future. Not a good solution either.

At this point I'm at the end of my rope. I have scoured Google and StackOverflow to learn more about how this new feature works, at a technical level, but details are sparse. If anyone has more information or experience with this, that would be great. Even if the answer is 'no dice'. Thanks!

zattacks
  • 21
  • 1
  • 1
    Good question. I'm facing the same problem. Apparently Apple has made a very casual decision on this. The only solution I can come up with is not blocking Apple's behavior, but responding to UIDeviceOrientation changes on iPadOS 15 if user is in iPhone interface. Of course, this totally violates the paradigm that codes about UI orientations should just depend on UIInterfaceOrientation, rather than on UIDeviceOrientation... – CrystDragon Jun 02 '22 at 10:10
  • What ended up working for me was applying a transform to the `UIImagePickerController` in `onDeviceOrientationChanged`. I had also tried responding to `traitCollectionDidChange` but IIRC the size classes for each orientation didn't actually change, and that method was never actually called. – zattacks Jun 03 '22 at 14:14

0 Answers0