简体   繁体   English

iOS通用应用程序Xcode 4入门技巧

[英]iOS universal app xcode 4 starter tips

I'm trying to start a universal app using Xcode and I'm totally lost. 我试图使用Xcode启动通用应用程序,但我完全迷路了。 I started the universal Window based app from the templates. 我从模板启动了基于通用窗口的应用程序。 I'm trying to have a UITableViewController for the iPhone, and a UISplitViewController for the iPad. 我正在尝试为iPhone设计一个UITableViewController,为iPad设计一个UISplitViewController。 I see 3 appDelegates, and did read this post http://www.kotancode.com/2011/04/05/ios-universal-apps/ , but I'm still really confused. 我看到了3个appDelegates,并确实阅读了这篇文章http://www.kotancode.com/2011/04/05/ios-universal-apps/ ,但我仍然很困惑。 I started by creating a UIViewController subclass in the iPadAppDelegate folder with a .xib. 我首先在iPadAppDelegate文件夹中使用.xib创建UIViewController子类。 Nothing is in the file yet. 文件中还没有任何内容。 Then in the iPadAppDelegate.h: 然后在iPadAppDelegate.h中:

@property (nonatomic, retain) IBOutlet HomeViewController_iPad *homeViewController;

Dragged a UIViewController in the MainWindow_iPad.xib, changed the class to HomeViewController, and tried dragging an outlet from the MainWindow to the UIViewController and I am not able to connect the HomeViewController. 在MainWindow_iPad.xib中拖拉UIViewController,将类更改为HomeViewController,然后尝试将插座从MainWindow拖到UIViewController,但我无法连接HomeViewController。

I thought I could do somthing like this for the iPhoneAppDelegate as well, but I believe I am missing something from the Universal App Template. 我以为我也可以为iPhoneAppDelegate做这样的事情,但是我相信通用应用模板中缺少一些东西。 Can someone give me some advice on how these 3 appDelegates work and how I can get started? 有人可以就这3个appDelegates的工作方式以及如何上手给我一些建议吗? TIA TIA

Universal Apps are really simple once you grasp how they work. 一旦掌握了通用应用的工作原理,通用应用就会非常简单。

The reason there are three AppDelegates is that you usually have one that is the base class for an iPhone and iPod specific app delegate. 之所以有三个AppDelegates,是因为您通常有一个作为iPhone和iPod特定应用程序委托的基类。 The entry-point into your iPhone or iPad Application is based on the configuration in your .plist file, if you select the project in xCode 4 it will show you a graphical configuration dialog that will allow you to change those properties. iPhone或iPad应用程序的入口点基于.plist文件中的配置,如果您在xCode 4中选择了项目,它将显示一个图形配置对话框,您可以通过该对话框更改这些属性。 The so called "Main Interface" is independently selectable for iPhone and iPad in the respective deployment section. 可以在相应的部署部分为iPhone和iPad独立选择所谓的“主界面”。 The Main Nib file does contain a serialized version of the device specific app delegate, which will then be "woken up" when the application is loading. Main Nib文件确实包含设备特定的应用程序委托的序列化版本,然后在加载应用程序时将其“唤醒”。 This process is triggered from your Main() method when 当您的Main()方法触发此过程时,

UIApplicationMain(argc, argv, nil, nil)

is called. 叫做。 UIApplicationMain does take care of loading the proper NIB file, based on the device it is run on. UIApplicationMain确实会根据运行它的设备来加载正确的NIB文件。

Thats all there is. 那就是全部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM