Where is MainWindow.xib in Xcode 4.2 ?
In Xcode 4.2 the MainWindow.xib is not included for some of the project templates. Its means now we have to generate GUI elements by code or we can reconstruct the MainWindow.xib in project. I am describing you the second option here.
If you create a new project in XCode 4.2, and choose the Empty Application template to start from, change nothing and try running it in your iPhone 5.0 simulator, you will see an empty – black – screen. The only thing you get from the template is an AppDelegate.h and AppDelegate.m.
We’ll now reconstruct the MainWindow.xib file in our project. So the next thing is now to create a empty user interface file. Choose iOS > User Interface > Empty as template. The name of this file is not very important but we’ll use MainWindow.xib because this name is familiar to us.
Now select the Empty MainWindow.xib file we just created in previous step.
Change the Class of File’s Owner to UIApplication
Now drop a Object from Library to Objects in xib file.
Change the class of that object to the AppDelegate class
Now add a window to objects pane.
Now we need to bind this window object to our code. To do this we have to add IBOutlet to window object in AppDelegate.h file. You code of AppDelegate.h should look like this -Note the IBOutlet just before UIWindow.
Now continue with editing MainWindow.xib file -
Control-Drag from the delegate outlet of the File Owner to the xAppDelegate object.
Control-Drag from the window outlet of the xAppDelegate to the Window.
Navigate to the project, and in the Summary tab, select MainWindow as the Main Interface.
We are almost done now.. But there is one more thing we need to fix. In AppDelegate.m, there was actually code that creates a window as well, so we have to delete this code.
We are done now
转载于:https://www.cnblogs.com/StarMud/articles/2497261.html
a2614555 原创文章 0获赞 0访问量 225 关注 私信- MainWindow.xib absence in Xcode 4.2 beta 4 with iOS 5 SDK
- MainWindow.xib absence in Xcode 4.2 beta 4 with iOS 5 SDK
- Use MainWindow.xib in XCode 4.2
- xcode4.2创建ios5 手动添加MainWindow.xib
- xcode4.2创建ios5 手动添加MainWindow.xib
- iPhone开发笔记[15/50]:指定启动的主界面XIB文件,在xcode4.2里可以不指定MainWindow.xib了
- Is a MainWindow.xib truly needed in iOS application?
- xcode4.2手动添加MainWindow.xib
- Xcode4.2自定义MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2中使用xib来运行hello world (MainWindow.xib)
- xcode 4.2 自己添加 MainWindow.xib