尝试使我的应用程序可同时用于iPhone 5和iPhone 4 / 4s。我尝试了“AutoLayout”,但似乎不适用于我的应用程序,还读取到它在iOS 5中不受支持。AutoLayout专门在具有UIScrollview和已在代码中重新设置大小的UIPicker的 View Controller 上特别失败。有两个 Storyboard ,一个为4英寸,一个为3.5英寸,似乎是可行的方法。
这两个Storyboard前驱似乎是我的解决方案。所以这给我两个问题。
最佳答案
这是一个很好的问题。
您需要做的是,
确保已选中Target和您的应用名称。
这使您可以重新排列此显示的所有内容。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
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){
storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone_5" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
}
}
return YES;
}
如果任何人都不知道如何执行步骤1,请执行以下操作。
MainStoryboard.storyboard
并重命名新的 Storyboard以说MainStoryboard5.storyboard
。 MainStoryboard5.storyboard
Add Files to ....
添加到项目中(在Xcode中)提示
完成上述所有操作后,您可能必须使用“产品>清洁”才能起作用。