iPhone 5自动布局不正确

时间:2012-10-17 23:31:42

标签: objective-c xcode storyboard iphone-5 autolayout

新的iPhone屏幕搞砸了我的应用程序。在iPhone 3.5英寸屏幕上,一切都不合适。我在同一个故事板中有两个不同的视图,我已经尝试检测并尝试切换故事板视图,但还没有任何工作。我可以获得一些关于如何在发布时切换到正确视图的代码吗?我是否将此代码放在我的主视图控制器中,还是将其放入我的应用程序代理中?

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
} else {
// code for 3.5-inch screen
}

What my views look like http://www.fileden.com/files/2012/6/18/3317719/screenshot7.jpg

1 个答案:

答案 0 :(得分:4)

在“didFinishLaunchingWithOptions:”中的应用程序的app delegate中初始化它,然后为设备/屏幕大小调用正确的NIB或Storyboard。为每个故事板创建一个不同的故事板,如果您希望在故事板中使用iOS 6的自动布局。用这样的东西开始你的if语句:

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0){
//iPhone 5 storyboard
}
else { 
// other storyboard here
}
相关问题