【发布时间】:2010-05-19 00:41:29
【问题描述】:
我需要弄清楚的原因是,在 iPad 上,UIPickerView 在横向上的高度与在纵向上的高度相同。在 iPhone 上是不同的。 iPad 编程指南为 UIDevice 引入了一个“惯用语”值:
UIDevice* thisDevice = [UIDevice currentDevice];
if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
// iPad
}
else
{
// iPhone
}
当您使用 iPad (3.2) 而不是 iPhone (3.1.3) 时可以正常工作 - 所以看起来还需要一个 ifdef 来有条件地编译该检查,例如:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200
UIDevice* thisDevice = [UIDevice currentDevice];
if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
// etc.
}
#endif
对我来说,这开始看起来很笨拙。有什么更好的方法?
【问题讨论】:
标签: iphone orientation ipad