因此,我有一个通用的应用程序,我正在设置UIScrollView的内容大小。显然,iPhones和iPads上的内容大小会有所不同。如何为iPads设置某个大小,并为iPhones和iPod touches设置另一个大小?
发布于 2011-08-13 05:40:08
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// The device is an iPad running iOS 3.2 or later.
}
else
{
// The device is an iPhone or iPod touch.
}发布于 2011-08-13 05:42:07
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)和
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)宏UI_USER_INTERFACE_IDIOM()还可以在旧的iOS版本上运行,例如iOS 3.0,而不会崩溃。
发布于 2013-12-19 01:05:57
UI_USER_INTERFACE_IDIOM()是最适合你的解决方案,因为你的应用是通用的。但如果你在iPad上运行iPhone应用程序,那么UI_USER_INTERFACE_IDIOM()将返回UIUserInterfaceIdiomPhone,而不管设备是什么。为此,您可以使用UIDevice.model属性:
if ([[UIDevice currentDevice].model rangeOfString:@"iPad"].location != NSNotFound) {
//Device is iPad
}https://stackoverflow.com/questions/7046539
复制相似问题