What is Root View Controller
When we do things like
[self.window addSu开发者_运维技巧bview:switchViewController.view];
Are we setting switchViewController as the rootViewController?
Actually no. rootViewController is a main controller. Callbacks such as didReceiveMemoryWarning will be sent to rootViewController only. And it must decide to whom it is addressed.
A window contain any amount of views. Some of them have UIViewControllers, some don't. So [self.window addSubview:switchViewController.view]; just add a view to a window, it doesn't know anything about its controller. The controllers should be manipulated by a rootViewController. The only way to set switchViewController as the rootViewController is to invoke something like self.rootViewController = switchViewController; in your AppDelegate file.
精彩评论