Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging the rootViewController of a UIWindow
    primarykey
    data
    text
    <p>When my app first loads, I set the <code>rootViewController</code> property of my <code>UIWindow</code> to <code>controllerA</code>. </p> <p>Sometime during my app, I choose to change the <code>rootViewController</code> to <code>controllerB</code>.</p> <p>The issue is that sometimes when I do a flip transition in <code>controllerB</code>, I see <code>controllerA</code>'s view behind it. For some reason that view isn't getting removed. Whats even more worrying is that after setting the <code>rootViewController</code> to <code>controllerB</code>, <code>controllerA</code>'s <code>dealloc</code> method never gets fired.</p> <p>I've tried removing the subviews of <code>UIWindow</code> manually before switching to <code>controllerB</code>, that solves the issue of seeing <code>controllerA</code>'s views in the background but <code>controllerA</code>'s dealloc still never gets called. <strong>Whats going on here????</strong></p> <p>Apples docs say:</p> <blockquote> <p>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. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.</p> </blockquote> <p><strong>UPDATE</strong></p> <p>Here's the code of my AppDelegate:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self showControllerA]; [self.window makeKeyAndVisible]; return YES; } - (void)showControllerA { ControllerA* a = [ControllerA new]; self.window.rootViewController = a; } - (void) showControllerB { ControllerB* b = [ControllerB new]; self.window.rootViewController = b; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload