xcode4.2手动添加MainWindow.xib
来源:互联网 发布:石油英语翻译软件 编辑:程序博客网 时间:2024/04/19 20:40
In the XCode 4.2 beta, MainWindow.xib is no longer included by default in some project templates. This means that you have to get your application to work by writing some code, using another method, or by manually reconstructing MainWindow.xib. This post shows the latter. Let’s get started.
If you create a new project in XCode 4.2 beta, 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 xAppDelegate.h and .m.
We will now reconstruct our own MainWindow.xib, to get started with development the way you’re used to. So the next thing we do is add a New File to the project.
Select the new File we just created. What we have now is an empty design surface, in what used to be Interface Builder. Here we’re going to change some things.
- Change the class of File’s Owner to UIApplication
- Find Object in the Library and drag it onto the Objects pane on the left.
- Change the class of that Object to the xAppDelegate class that was created by the template, you might also want to clear out the “Object” label.
- Add a Window to the Objects pane on the left.
Now, let’s bind it all together. To do this, we first need to change some of the code in the xAppDelegate.h. We have to add IBOutlet to the window property it has, so that we can
@interface DemoAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) IBOutlet UIWindow *window; @end
Don’t forget to save the file, otherwise Interface Builder will not be able to pick up the Outlet. Next we continue editing the MainWindow.xib
- 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.
- Just for this demo, I’m adding a label to the window.
We’re not done yet, but we’re almost there.
- Navigate to the project, and in the Summary tab, select MainWindow as the Main Interface.
You can now run the project in the Simulator, and the window should show up. However there’s one last thing you might want to clean up. In xAppDelegate.m, there was actually code that creates a window as well. Just put the method
- (BOOL) application:didFinishLaunchingWithOptions:
in comment.
I hope this helps to understand exactly how an iOS app starts. The next thing you should do is add a ViewController, and push it onto the MainWindow. I’m not going to cover that here. Please leave your feedback in the comments.
转自:http://blog.sina.com.cn/s/blog_4f1d20f30100twtd.html
- xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2创建ios5 手动添加MainWindow.xib
- xcode4.2创建ios5 手动添加MainWindow.xib
- xcode4.2 MainWindow.xib
- xcode4.2 MainWindow.xib
- IOS_xcode4.2手动添加MainWindow.xib
- Xcode4.2自定义MainWindow.xib
- 在XCode4.2中添加MainWindow.xib文件
- 在XCode4.2中添加MainWindow.xib文件
- Xcode4.2下iPhone多视图开发(自已创建MainWindow.xib和不用MainWindow.xib两种实现)
- Xcode4.2下iPhone多视图开发(自已创建MainWindow.xib和不用MainWindow.xib两种实现)
- Xcode4.0版本自己创建MainWindow.xib
- xcode4.2中使用xib来运行hello world (MainWindow.xib)
- iPhone开发学习笔记007——Xcode4.2下iPhone多视图开发(自已创建MainWindow.xib和不用MainWindow.xib两种实现)
- iPhone开发学习笔记007——Xcode4.2下iPhone多视图开发(自已创建MainWindow.xib和不用MainWindow.xib两种实现)
- xcode 4.2 自己添加 MainWindow.xib
- 关于 CFileDialog 对话框多选功能的一个问题
- BC-SAP另一个发送邮件相关配置
- python 如何调用带参数的shell脚本
- Jquery获取浏览器宽高的代码
- oracle常用信息查询
- xcode4.2手动添加MainWindow.xib
- 关于linq学习的几个网站
- permission和uses-permission的区别 .
- 内存堆和栈的区别
- 推荐一系列优秀的Android开发源码
- NHibernate:no persister for 异常
- ant
- php的安装
- 递归,回溯,合并,动态规划算法笔记