#define
写代码appdelegate
类
+(NSString *)isAppRunningOnIpad:(NSString *)strNib{
NSString *strTemp;
NSString *deviceType = [UIDevice currentDevice].model;
if ([deviceType hasPrefix:@"iPad"]){
strTemp=[NSString stringWithFormat:@"%@I",strNib];
}
else{
strTemp=strNib;
}
return strTemp;
}
调用该从你的类在编译时您的计算机上得到解决,即
显然,你不能让他们合作按照你想要的方式。我建议创建static
变量并将它们设置为您班级的+(void)initialise
方法。
而且为条件,使用类似
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// iPad
} else {
// iPhone or iPod touch.
}
因此,这将去
static NSInteger foo;
@implementation bar
+(void)initialise{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// iPad
foo = 42;
} else {
// iPhone or iPod touch.
foo = 1337;
}
}
@end
我想我会尝试第二个选项,如果它工作正常我会标记你的答案是正确的:) – Lolloz89 2012-08-08 10:05:40
伟大的拍摄感谢 – 2012-08-29 10:13:16
哇好的答案 – Spynet 2013-03-28 11:52:57