如果没有拍摄xib文件,视图控制器如何与iphone 5兼容。是否有可能以编程方式进行更改。 提前谢谢。
答案 0 :(得分:0)
检查设备是否为iPhone 5并设置框架编程..
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
if (screenRect.size.height >= 548 )
{
// set your frame for iPhone 5
}else
{
// set your frame for iPhone 4
}
答案 1 :(得分:0)
是的,您可以通过添加以下条件
来实现CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
iPhone 4 or less
}
else if (result.height == 568)
{
iPhone 5 condition
}
您想要区分两部手机的位置。
答案 2 :(得分:0)
是的,你可以做到这一点。 XIB只是在texteditor中打开一个文件 - 你会发现它包含可读的xml代码。现在为了使viewController与Iphone 5兼容,只要把if条件和通过检查特定设备的高度分别为不同的设备制作东西
但挑衅性的是长期工作
对于我的通用应用程序,外汇应用程序,我只是使用屏幕高度检测概念,如下所示:
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (screenSize.height > 480.0f) {
/*Do iPhone 5 stuff here.*/
} else {
/*Do iPhone Classic stuff here.*/
}
} else {
/*Do iPad stuff here.*/
}