Pet*_*zes 29 xcode objective-c uiscrollview ios
所以我有一个通用的应用程序,我正在设置一个内容大小UIScrollView.显然,iPhone和iPad上的内容大小会有所不同.如何为iPad设置一定的尺寸,为iPhone和iPod touch设置另一种尺寸?
Pet*_*zes 92
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.
}
Run Code Online (Sandbox Code Playgroud)
Jus*_*Sid 14
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
Run Code Online (Sandbox Code Playgroud)
和
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
Run Code Online (Sandbox Code Playgroud)
宏UI_USER_INTERFACE_IDIOM()也可以在iOS 3.0等旧iOS版本上运行而不会崩溃.
UI_USER_INTERFACE_IDIOM()因为您的应用程序是通用的,所以是您的最佳解决方案.但是,如果您在iPad上运行iPhone应用程序而不是UI_USER_INTERFACE_IDIOM()返回UIUserInterfaceIdiomPhone,则无论使用何种设备.出于这样的目的,您可以使用该UIDevice.model属性:
if ([[UIDevice currentDevice].model rangeOfString:@"iPad"].location != NSNotFound) {
//Device is iPad
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25503 次 |
| 最近记录: |