0

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.

inexcii
  • 1,591
  • 2
  • 15
  • 28
  • I run your code, I didn't find anything magnifying, neither two white box, nothing else. can you eloborate more? – Chatar Veer Suthar Aug 07 '19 at 11:35
  • hi, @ChatarVeerSuthar thank you for replying my question. I've updated the question(in the 'Update' part) for you so please refer it again. – inexcii Aug 07 '19 at 14:07

1 Answers1

0

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.
Chatar Veer Suthar
  • 15,541
  • 26
  • 90
  • 154
  • Thank you for the replying. The demo is just a simplified version of this issue. Actually in our production app, we have much complicated view-combinations such as UINavigationController, some customized PageControl header in UICollectionView, all these combined parts result in that the flickering happens **every time** when we navigate to the sub-UIViewController. And the magnified effect gets stronger sometime when we change the UI or transition code. – inexcii Aug 08 '19 at 08:34
  • Did you try to put code in DispatchQueue.main.async { //Your navigation code here } – Chatar Veer Suthar Aug 08 '19 at 08:39
  • No, I didn't. May I ask which part of code should I put into the main-thread block? – inexcii Aug 08 '19 at 08:41
  • The navigation push and pop or present and dismiss, put in DispatchQueue.main.asyc { } block. than see what happens. – Chatar Veer Suthar Aug 08 '19 at 08:42
  • Give me some time, so I can work on your demo to get solution in code. – Chatar Veer Suthar Aug 08 '19 at 08:47