开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜