试图让我的应用程序同时使用iPhone 5和iPhone 4/4。我尝试了" AutoLayout“,但似乎对我的应用程序不起作用,还读到iOS 5中不支持它。AutoLayout在具有UIScrollview和在代码中调整大小的UIPicker的视图控制器上特别失败。有两个故事板,一个为4英寸,另一个为3.5英寸似乎是可行的。
两个故事板似乎是我的解决方案。这给我留下了两个问题;
发布于 2012-09-21 19:43:35
,这是一个很好的问题。
你需要做的是
如果没有人知道如何执行第1步,请按以下步骤执行.
MainStoryboard.storyboard并重命名新的故事板,如MainStoryboard5.storyboard。MainStoryboard5.storyboard (在Xcode中),方法是右键单击project并单击Add Files to ....Tip
您可能需要使用“产品>清洁”才能在您完成上述所有操作后才能工作。
发布于 2012-09-21 19:35:00
目前,唯一的方法是检查是否使用iPhone 5是[UIScreen mainScreen] bounds]和[[UIScreen mainScreen] scale]。
BOOL isIphone5 = (([[UIDevice currentDevice] userInterfaceIdiom]
== UIUserInterfaceIdiomPhone) && (([UIScreen mainScreen].bounds.size.height *
[[UIScreen mainScreen] scale]) >= 1136));这只有在您至少向应用程序添加了Default-568h@2x.png启动映像时才能工作。否则这将永远是假的。(因为如果没有启动映像,屏幕将被封上字母)
要将故事板设置为iPhone 5版本,您可能需要查看this question
发布于 2012-10-10 17:23:28
我从fields.cage答案中获得灵感,并将其改编为我的代码,它运行得很好。谢谢!!
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
UIStoryboard *storyBoard;
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 1136){
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone5" bundle:nil] autorelease];
}
else
{
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
}
}https://stackoverflow.com/questions/12536689
复制相似问题