Reputation: 56
The new iPhone screen has screwed up my app. On the iPhone 3.5 inch screen, everything is out of place. I have two different views in the same storyboard I have tried out detecting and trying to switch storyboard views but nothing has worked yet. Could I get some code on how to switch to the right view at the launch? Do I place this code in my main view controller, or do I put this in my app delegate?
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
Upvotes: 0
Views: 551
Reputation: 56
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
}
Upvotes: 4