ipad和iphone之间的条件编译 [英] Conditional Compilation between ipad and iphone

查看:219
本文介绍了ipad和iphone之间的条件编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以及运行时检查决定iphone / ipad应用程序的代码路径,有没有条件编译标志任何地方,可以用来减少代码大小?

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.

其他人怎么做?

感谢

推荐答案

您可以使用以下函数检查 isPad 然后为 iPad 执行代码 iPhone

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
}

这篇关于ipad和iphone之间的条件编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆