I think the reason why it's now absent is that creating a window programmatically is much more efficient than opening a xib file and unarchiving the objects. Generally, if you can do it in one line of code, you should do that in code.
It is has always been an option not to use MainWindow.xib. The UIWindow could be loaded programmatically by the doing the following:
1) Making sure that the call to UIApplicationMain in main.m looks like this:
UIApplicationMain(argc, argv,nil,@"MyAppDelegateClassName");
rather than this:
UIApplicationMain(argc, argv,nil,nil);
2) Making sure that Info.plist does not have a value of "MainWindow.xib" as the main nib file.
3) Loading the UIWindow programmatically in the app delegate.
So, no, you don't have to use MainWindow.xib and, actually, you never have. You could always do things programmatically.
It is a good question why Apple made this change in the default Xcode settings, and I don't know the answer. But it may have to with performance or the transition to ARC or small application file sizes or something else altogether.
本文探讨了在iOS应用中不使用MainWindow.xib文件而通过代码程序化加载UIWindow的方法,指出这种方式比解压缩.xib文件更高效。文章详细介绍了如何在main.m文件中配置UIApplicationMain调用,并确保Info.plist中没有指定MainWindow.xib作为主Nib文件,最后在AppDelegate中程序化加载UIWindow。
1511

被折叠的 条评论
为什么被折叠?



