Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

iphone - self.window.rootViewController vs window addSubview

I've noticed a lot of examples for iPhone apps in the Application Delegate

- (void)applicationDidFinishLaunching:(UIApplication *)application

have

[window addSubview: someController.view]; (1)

as opposed to

self.window.rootViewController = self.someController; (2)

Is there any practical reason to use one over the other? Is one technically correct? Do controller's have an equivalent command to number (2) like

self.someController.rootController = self.someOtherController; // pseudocode

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The UIWindow rootViewController property is new with iOS4.

The older technique was to use addSubview.

The new, recommended technique is to set rootViewController.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...