开发者

Universal application

How to make universal app for i开发者_如何学Gophone and ipad. How we detect the device whether it is for iPhone or iPad?


The easiest way would be using UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad and UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone.


in Xcode 3

select your target in Xcode, right-click and use the “Upgrade Current Target for iPad…” command.

in Xcode 4

click on the project and go to the target. In Summary tab, change Device to Universal.

I used

UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad

for detecting iPad.


Personnally, I used this method in my appdelegate

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜