[英]Anyone has a tutorial on how to create Universal app with XCode 4.2?
It looks like things changed with XCode 4.2 and I did not see any guide/tutorial on how to create a Universal app with XCode 4.2. 看起来XCode 4.2的内容发生了变化,我没有看到任何关于如何使用XCode 4.2创建通用应用程序的指南/教程。 Anyone knows one or wrote one? 谁知道一个或写一个?
Note: I'm not talking about how to select your project to be Universal, I'm talking about a Hello World tutorial. 注意:我不是在谈论如何选择你的项目是Universal,我在谈论Hello World教程。
Thanks, 谢谢,
In case you actually wanted a plain source, compilable as a universal app that writes Hello World
into the console, depending on the device in use, here comes a tiny snippet for you. 如果你真的想要一个简单的源代码,可编译为将Hello World
写入控制台的通用应用程序,具体取决于所使用的设备,这里有一个小小的片段。
main.m 的main.m
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
printf("hello world, from my iPad");
}
else
{
printf("hello world, from my iPhone or iPod");
}
return 0;
}
Within the build settings of your app, you will have to select: 在您的应用的构建设置中,您必须选择:
TARGETED_DEVICE_FAMILY = 1,2
Like this: 像这样:
Xcode will create a project with 2 initial XIBs with same names and different suffix _iPhone and _iPad. Xcode将创建一个项目,其中包含2个具有相同名称和不同后缀_iPhone和_iPad的初始XIB。
Enjoy! 请享用!
Good luck! 祝好运!
Look for any Hello World
iPhone OR iPad app. 寻找任何Hello World
iPhone或iPad应用程序。 Make sure you set the project to Universal. 确保将项目设置为Universal。
Try : 试试:
Head First iPhone and iPad Development, 2nd Edition A Learner's Guide to Creating Objective-C Applications for the iPhone and iPad By Dan Pilone, Tracey Pilone Head First iPhone和iPad开发,第2版为iPhone和iPad创建Objective-C应用程序的学习者指南作者:Dan Pilone,Tracey Pilone
They have a great section on Universal Apps :) 他们在Universal Apps上有很棒的部分:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.