开发者

MainWindow .xib - iPhone Development

开发者 https://www.devze.com 2023-03-19 05:16 出处:网络
It is my understanding that every view has it\'s own controller class. I know generally that the xib file is the application vi开发者_如何转开发ew/subview. My question is does the MainWindow.xib have

It is my understanding that every view has it's own controller class. I know generally that the xib file is the application vi开发者_如何转开发ew/subview. My question is does the MainWindow.xib have it's own controller and if so, where can it be found?


You are right in that a xib file can allow to associate a view to its view controller.

Now, MainWindow.xib contains the main UIWindow for your app (at least). UIWindow is not a UIView and does not need a UIViewController.

On the other hand, you can create any object you like inside of a MainWindow.xib, so you can also have a UIView in there, which you then add to the UIWindow instance, and its corresponding UIViewController.

If you think about additional xibs, what happens with them is that they define a UIView, and additionally also specify the File's Owner type, which is usually UIViewController and gets instantiated by loading the xib.

In this sense, MainWindow.xib, though not requiring a UIViewController, still needs a File's Owner, and this is the UIApplication singleton. Since you cannot modify nor derive a class from UIApplication, the way to interact with the UIWindow instance is through the UIApplication's delegate.

Take in mind that MainWindow.xib plays a special role, in that it is also specified in the info.plist file. You can do without one (by removing the corresponding entry from info.plist) and simply declare your application delegate when calling UIApplicationMain from main.c. In this case, nor application delegate neither the UIWindow will be instantiated through the xib mechanism; you will need to instantiate a UIWindow from you application delegate's applicationDidFinishLaunching.


I don't think it has its own controller. It is the main window basically the thing that pops up when application comes up. We add controllers or view controllers for the user to use. App delegate is sort of the controller but not exactly. we override applicationDidFinishLaunchingWithOptions to any controllers etc so appdelegate can be thought of as the controller of the mainwindow.xib although it isnt.

0

精彩评论

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