问题
I started a new project in Xcode 4 using the TabBar template.
I noticed that there was no MainWindow.xib
file in the project.
- Did Apple get rid of this file?
- How can I access the Mainwindow without this file?
回答1:
MainWindow.xib was kind of superfluous to begin with, keeping in mind that it doesn't really contain any "visible" components (thinking of the window as an invisible container) and that usually you don't need to modify it. (That said, I'm only a beginner in iOS development myself, so I would appreciate my observation being corrected if I'm wrong).
MainWindow.xib's role in the beta version has been replaced by code: compare the auto-generated (-)application:didFinishLaunchingWithOptions: of the same template in the current and beta version of Xcode, and you should be able to follow what's happening.
回答2:
If you are using the iOS SDK beta please read the release notes and the "What's new in iOS" document. You can find the documents on developer.apple.com when logged in as an iOS Developer Program member.
回答3:
I just created a blank tab bar project in Xcode 4 and the MainWindow.xib is there. Maybe you deleted it by accident. Try creating a new project from scratch, it should be there.
回答4:
There's a nice video tutorial on Youtube explaining how to re-create MainWindow.xib
from scratch:
http://www.youtube.com/watch?v=sROdA4w4x9Y
回答5:
For the reason of MainWindow.xib been missed, you can refer to this answer. And you can refer to Is a MainWindow.xib truly needed in iOS application? for more discussion.
In fact, you need not a MainWindows.xib. You can look up the implementation code of your AppDelegate class's method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
which will tell you how you xib files are loaded and connected to the window.
And you should look up your main.m, you will find code like this
UIApplicationMain(argc, argv, nil, @"MyAppDelegateClassName");
or
UIApplicationMain(argc, argv, nil, NSStringFromClass([myAppDelegate class]));
rather than
UIApplicationMain(argc, argv, nil, nil);
This statement make your AppDelegate loaded.
来源:https://stackoverflow.com/questions/6446972/where-is-mainwindow-xib-in-new-xcode-project