Iphone 普遍适用

Iphone 普遍适用,iphone,ipad,hardware,device,Iphone,Ipad,Hardware,Device,如何为iphone和ipad制作通用应用程序。我们如何检测设备是iPhone还是iPad?我个人在appdelegate中使用了这种方法 + (BOOL)isPad { NSLog(@"--------- %@ ---------", [[UIDevice currentDevice] model]); NSRange range = [[[UIDevice currentDevice] model] rangeOfString:@"iPad"]; return !(ra

如何为iphone和ipad制作通用应用程序。我们如何检测设备是iPhone还是iPad?

我个人在appdelegate中使用了这种方法

+ (BOOL)isPad
{
    NSLog(@"--------- %@ ---------", [[UIDevice currentDevice] model]);
    NSRange range = [[[UIDevice currentDevice] model] rangeOfString:@"iPad"];
    return !(range.location==NSNotFound);
}

最简单的方法是在Xcode 3中使用
UI\u用户界面习惯用法()==UIUserInterfaceIdiomPad
UI\u用户界面习惯用法()==UIUserInterfaceIdiomPhone

在Xcode中选择您的目标,右键单击并使用“升级iPad的当前目标…”命令

在Xcode 4中

单击项目并转到目标。在摘要选项卡中,将设备更改为通用

我曾经

UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad

用于检测iPad。

如果我想检测iPod和iPhone,那么:UI\u USER\u INTERFACE\u IDIOM()?