1

I've been dealing with a UI glitch on iPadOS 13.1.3 that is related to device orientation. Is there any solution or workaround for this?


Issue

Description

Let's have screen A that displays modally screen B. Screen A is locked to portrait only and screen B supports all orientations. If screen A is displayed, device is rotated to landscape then and screen B is about to be displayed, screen A is resized incorrectly first which results a wierd glitch.

Images

The left images is taken on iPadOS 13.1.3 that produces the UI glitch. Image on the right is recorded on iPad with iOS 12.4.1 installed where the layout is correct. All the attached images are part of the github project linked below.

Project

Please, feel free to have a closer look on the issue by using this repository.

Thanks.


Edit:

The glitch no longer occurs on iPadOS 13.2.

Fiser33
  • 286
  • 1
  • 10
  • The recordings were both taken in landscape, it's just that I did not rotate them manually. Your findings are interesting as I am able to reproduce the glitch 100% times, both on iPad simulator (running iPadOS 13.1) and real iPad devices (running iPadOS 13.1.2 and 13.1.3), all by using Xcode 11.1 (11A1027). It does not matter if I launch the app in landscape or rotate it when blue screen is on (not flat, but real landscape). Do you use the same configuration and steps to reproduce (described in repo)? – Fiser33 Oct 24 '19 at 06:45

1 Answers1

0

I worked around it like this:

  • Delete your implementation of func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?). Let's let the view controllers handle this.

  • In VC1:

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .portrait
    }
    

    Also delete the "hacky solution".

  • In VC2:

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .all
    }
    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        .portrait
    }
    

So what we get is that VC2 appears initially in portrait but can then be rotated.

If you want VC2 to rotate immediately into landscape after appearing, then add this:

var appeared = false
override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    appeared = true
    UIViewController.attemptRotationToDeviceOrientation()
}
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Thanks matt! I was affraid that I'll have to allow more orientations in project settings but it works with no change made. Also I like the rotation being triggered from detail controller, even though this introduces rotation animation. Marked as accepted answer as this removes the described glitch. – Fiser33 Oct 29 '19 at 10:26