开发者

Conditional Compilation between ipad and iphone

开发者 https://www.devze.com 2023-04-06 21:20 出处:网络
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 d

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

精彩评论

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