inexcii
inexcii

Reputation: 1631

Safe area constrained views get magnified with status bar toggled hidden/unhidden when navigating between UIViewControllers in iOS

Like the title says, there is an unexpected behavior that safe area constrained views get magnified on iOS when you try to navigate between UIViewControllers while toggling status bar hidden/unhidden.

A reproducible project can be found here.

I wonder if this is a bug in iOS. Hope someone can explain why the issue happens and how can we fix it.

Update:

For "get magnified" part above:
The issue only happens at a glance, 2-3 times out of 5, during the UIViewController's navigation so you may have to pay much attention so as to notice it.
The magnified parts are: green background and two white boxes.
Note that the views keep the same size before-and-after the navigation.

Also, in the project, you might want to tap 'Button' and 'Close' button continuously so that it switches very quickly, to easily get issue noticed.

Upvotes: 0

Views: 80

Answers (1)

Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

Problem:

Your code for hiding status bar & changing orientation causing flickering. Actually this works in background thread & you press Button and Close buttons so quickly that you feel it. OS is under transition which will effect your height of view.

override var prefersStatusBarHidden: Bool {
    return true
}

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return [ .landscape ]
}

Solution:

  1. Don't let user go back and forth so quickly until previous dismiss is not completed (completion handler)
  2. Use Transition animation to lower the effect visually to end user.

Upvotes: 0

Related Questions