开发者

Conditional Compilation between ipad and iphone

As well as runtime checks for deciding on code paths for an iphone/ipad app, is there a conditional compilation flag anywhere that can be used to reduce code size? Apple seems to suggest it in their development notes, but开发者_开发百科 I can't find anything anywhere.

How do others do this?

Thanks


You can use the following function and check for if isPad then do code for iPad else code for iPhone

- (BOOL) isPad{ 
#ifdef UI_USER_INTERFACE_IDIOM
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
    return NO;
#endif
}

if([self isPad])
{
//do code for iPad
}
else
{
//do code for iphone
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜