If we are using storyboards we can handle different sizes by creating different storyboards for iPhone 4 and iPhone 5 and handle them in didFinishLaunching method of AppDelegate in this way :
Here for iPhone 4 we have storyboard named "Main_iPhone_4s" and for iPhone 5 we have storyboard named "Main_iPhone"
UIViewController *initialViewController;
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
// iPhone 4
if (iOSDeviceScreenSize.height == 480)
{
// Instantiate iPhone 4 storyboard
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone_4s" bundle:nil];
// Instantiate the initial view controller object from the storyboard
initialViewController = [iPhone35Storyboard instantiateInitialViewController];
}
// iPhone 5
if (iOSDeviceScreenSize.height == 568)
{
// Instantiate iPhone 5 storyboard
UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
// Instantiate the initial view controller object from the storyboard
initialViewController = [iPhone4Storyboard instantiateInitialViewController];
}
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
0 Comment(s)