开发者

How would I change the default loaded view controller in Xcode?

How would I do this? Is it simple enough to explain clearly? If not, a tutorial would be nice. I checked the web and this site and still couldn't find exactly what I was looking fo开发者_开发技巧r.


The default XIB file loaded when your application start is MainWindow.xib by default.

If you want you app to load another XIB instead, this can be changed in the Info.plist file of your project.

In this XIB loaded when the app is launched (MainWindow.XIB by default), you will find:

  • a placeholder for the File's Owner (like in any XIB) which in the case of the XIB loaded by the application on startup is the UIApplication itself.
  • a UIWindow (the main and unique window of your iPhone app),
  • an object that acts as the delegate of your UIApplication (commonly called "the AppDelegate")
  • And probably a UIViewController too.

When the XIB is loaded at startup, the AppDelegate objet is instanciated (like all objects in the XIB except the File's Owner) and as it is set as the delegate of the application, application:didFinishLaunhcingWithOptions: will be executed. This code then generally add the viewController's view as a subview of your app window using a line like [self.window addSubview:self.viewController.view]. (As your AppDelegate have an IBOutlet that points to the ViewController in the XIB)


If you need to change the class of the ViewController used in your MainWindow.xib, change the class of the UIViewController in Interface Builder, and also change the type of the associated IBOutlet in the AppDelegate header file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜