notes icon indicating copy to clipboard operation
notes copied to clipboard

iOS old rootViewController remains

Open onmyway133 opened this issue 8 years ago • 3 comments

  • Set A as rootViewController
  • A presents B (it is only a problem if present)
  • Set C as rootViewController. Try to A.dismiss before
  • A deinit
  • We see C. But A view is behind, still there 😱

=> Change root view controller in dismiss completion block, even if the animated is false. Check for presentedViewController before dismiss

onmyway133 avatar Dec 13 '16 14:12 onmyway133

The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.

onmyway133 avatar Dec 13 '16 14:12 onmyway133

  • http://stackoverflow.com/questions/17632024/changing-the-rootviewcontroller-of-a-uiwindow
  • http://stackoverflow.com/questions/26795825/uiwindow-setrootviewcontroller-not-clearing-existing-hierarchy

onmyway133 avatar Dec 13 '16 14:12 onmyway133

An even simpler solution is to set the backgroundColor of your new window to .white or any color. The default is nil, which results in a transparent background. That is why the older window (on top of which the new one is made visible) is being seen through.

h0shy avatar Nov 21 '19 17:11 h0shy