开发者

What is Root View Controller

开发者 https://www.devze.com 2023-03-01 07:10 出处:网络
When we do things like [self.window addSu开发者_运维技巧bview:switchViewController.view]; Are we setting switchViewController as the rootViewController?Actually no. rootViewController is a main cont

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

精彩评论

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