Where is MainWindow.xib in new Xcode project?

2019-04-21 02:10发布

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?

5条回答
Bombasti
2楼-- · 2019-04-21 02:44

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.

查看更多
做个烂人
3楼-- · 2019-04-21 02:54

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.

查看更多
甜甜的少女心
4楼-- · 2019-04-21 02:55

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.

查看更多
来,给爷笑一个
5楼-- · 2019-04-21 03:01

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.

查看更多
Emotional °昔
6楼-- · 2019-04-21 03:05

There's a nice video tutorial on Youtube explaining how to re-create MainWindow.xib from scratch:

http://www.youtube.com/watch?v=sROdA4w4x9Y

查看更多
登录 后发表回答