XCode4.2中使用Empty Application模板替代旧的Window Based Application
来源:互联网 发布:第一财经软件 编辑:程序博客网 时间:2024/05/18 01:05
I had upgraded Xcode to 4.2 beta 4 and realised that there is no more templates for iOS 4.
Obviously, it did not include iOS 4 SDK because it said “with iOS 5 SDK”, duh!
I could not go back to Xcode beta 3 since I upgraded my iPhone to beta 4 as well.
Anyway…
In the tutorial that I am learning at the moment, it requires “Window-based application”.
Xcode 4.2 beta 4 does not have “window-based application”; so, I created a project with “Empty application”.
Unfortunately, “Empty application” has no longer “MainWindow.xib”, which tutorial teacher said to modify something in it.
So, I googled to make “MainWindow.xib” visible and found this article.
“MainWindow.xib” posted by Jeroen Trappers
------------------------------------------------------------------------------------------------------------------
MainWindow.xib
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 anxAppDelegate.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. ChooseiOS > User Interface > Empty as template. Next, choose iPhone, next give it the name MainWindow (.xib will be added automatically). By the way, the name of the file is not very important, but it’s nice to chooseMainWindow, because that’s familiar.
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 hook it up in Interface Builder. The xAppDelegate.h should read something like this:
@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. InxAppDelegate.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.
kthxbye
- XCode4.2中使用Empty Application模板替代旧的Window Based Application
- XCode4.2中使用Empty Application模板替代旧的Window Based Application
- XCode4.2中使用Empty Application模板替代旧的Window Based Application
- Xcode4.2中 添加 Window-Based Application 模板
- xcode4.3 中Storyborad 替代了window based application
- 从Empty Application到Window Based Application
- 为XCODE4.3 添加 Window-Based Application 模板
- 在xcode4.3.1中如何创建 window-based Application 工程。
- ios学习笔记(五)xcode4.3.2中添加Window-Based Application模版
- XCode4.2中没有Window Base Application解决办法
- 在Xcode6中找回失去的模板Empty Application
- Xcode7.2中如何添加一个Empty Application模板
- Xcode建立Window based Application
- Xcode7 Empty Application 模板添加
- 在Xcode6中添加category、protocol、Empty Application模板
- xcode 4.2 不再支持 Window-Based Application 的解决办法
- xcode 4.2 不再支持 Window-Based Application 的解决办法
- xcode 4.3 不再支持 Window-Based Application 的解决办法
- JPEG+简易文档+V2.11
- AAC 文件解析及解码流程
- 好的学习linux内核的网站
- 给程序设置老板键
- 《web前端开发修炼之道》读书笔记
- XCode4.2中使用Empty Application模板替代旧的Window Based Application
- C# 电子邮件发送方法
- 轻松解决SQL Server无法启动的小技巧
- objective C 基础教程
- 函数指针
- 事件的理解
- 类型化的数据集和非类型化数据完成增删改查的操作
- EditorGrid
- Android进阶篇-自定义Menu(设置Menu的背景及文字属性)