I am upgrading my app as per iPhone 5 method and got the way but just need help regarding the following point:
How do I use an if else condition to make the app choose the .xib file when made to run on different iPhones, especially iPhone 5?
I am upgrading my app as per iPhone 5 method and got the way but just need help regarding the following point:
How do I use an if else condition to make the app choose the .xib file when made to run on different iPhones, especially iPhone 5?
xib
您应该能够利用 Interface Builder 中的自动调整大小掩码和/或自动布局来实现此目的,而无需为每个 iPhone 设备外形创建一个全新的文件。
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{//do iPad stuff
}
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
{//do iPhone stuff
}
对于图像,您可以在苹果开发网站上查找命名约定。我相信 iPhone 5 使用的是“-568h@2x.png”结尾。iPad 带有“~ipad.png”和“@2x ~ipad.png”。2x 用于视网膜显示器。
如果您想知道底层设备是 iPhone 5 或不使用以下代码:
if ([UIScreen mainScreen].bounds.size.height == 568)
{
// Write whatever you want here.
NSLog(@"Hello from iPhone5");
}