0

新的 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
}

我的观点是什么样的 http://www.fileden.com/files/2012/6/18/3317719/screenshot7.jpg

4

1 回答 1

4

Initialize this in the app delegate for the app in "didFinishLaunchingWithOptions:" and then call the right NIB or Storyboard for the device/screen size. Create a different Storyboard for each and if you wish use auto layout for iOS 6 in your Storyboard. Start your if Statement with something like this:

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0){
//iPhone 5 storyboard
}
else { 
// other storyboard here
}
于 2012-10-18T00:46:36.220 回答