iOS Tabbed Application switches back to iPhone 4 resolution on iPhone 5
when switching tabs
I have a tabbed application which which has five tabs on iPhone 5. Every
view controller that will be loaded to each tab has a separate nib file
for iPhone4 and iPhone5.
When the application loads on iPhone 5, the first page is OK, meaning it
uses the whole screen (320x568). However, when I switch tabs, it uses the
iPhone 4 resolution (320x480).
Below is my code located on my app delegate, inside appl:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]
bounds]];
// Override point for customization after application launch.
if ([[UIScreen mainScreen] bounds].size.height == 568) {
UIViewController *topView = [[KaomojiTopPageViewController
alloc]initWithNibName:@"KaomojiTopPageViewController-568h"
bundle:nil];
self.rankingView = [[KaomojiRankingViewController
alloc]initWithNibName:@"KaomojiRankingViewController-568h"
bundle:nil];
self.categoryView = [[KaomojiCategoryViewController
alloc]initWithNibName:@"KaomojiCategoryViewController-568h"
bundle:nil];
self.bookmarkView = [[KaomojiBookmarkViewController
alloc]initWithNibName:@"KaomojiBookmarkViewController-568h"
bundle:nil];
self.dictionaryView = [[KaomojiDictionaryViewController
alloc]initWithNibName:@"KaomojiDictionaryViewController-568h"
bundle:nil];
self.settingsView = [[KaomojiSettingsViewController
alloc]initWithNibName:@"KaomojiSettingsViewController-568h"
bundle:nil];
self.navRankingView = [[UINavigationController alloc]
initWithRootViewController:self.rankingView];
self.navCategoryView = [[UINavigationController alloc]
initWithRootViewController:self.categoryView];
self.navBookmarkView = [[UINavigationController alloc]
initWithRootViewController:self.bookmarkView];
self.navDictionaryView = [[UINavigationController alloc]
initWithRootViewController:self.dictionaryView];
self.navSettingsView = [[UINavigationController alloc]
initWithRootViewController:self.settingsView];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[navRankingView,
navCategoryView, navBookmarkView, navDictionaryView,
navSettingsView];
self.window.rootViewController = self.tabBarController;
[self.navCategoryView addChildViewController:topView];
}else{
UIViewController *topView = [[KaomojiTopPageViewController
alloc]initWithNibName:@"KaomojiTopPageViewController" bundle:nil];
self.rankingView = [[KaomojiRankingViewController
alloc]initWithNibName:@"KaomojiRankingViewController" bundle:nil];
self.categoryView = [[KaomojiCategoryViewController
alloc]initWithNibName:@"KaomojiCategoryViewController"
bundle:nil];
self.bookmarkView = [[KaomojiBookmarkViewController
alloc]initWithNibName:@"KaomojiBookmarkViewController"
bundle:nil];
self.dictionaryView = [[KaomojiDictionaryViewController
alloc]initWithNibName:@"KaomojiDictionaryViewController"
bundle:nil];
self.settingsView = [[KaomojiSettingsViewController
alloc]initWithNibName:@"KaomojiSettingsViewController"
bundle:nil];
self.navRankingView = [[UINavigationController alloc]
initWithRootViewController:self.rankingView];
self.navCategoryView = [[UINavigationController alloc]
initWithRootViewController:self.categoryView];
self.navBookmarkView = [[UINavigationController alloc]
initWithRootViewController:self.bookmarkView];
self.navDictionaryView = [[UINavigationController alloc]
initWithRootViewController:self.dictionaryView];
self.navSettingsView = [[UINavigationController alloc]
initWithRootViewController:self.settingsView];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[navRankingView,
navCategoryView, navBookmarkView, navDictionaryView,
navSettingsView];
self.window.rootViewController = self.tabBarController;
[self.navCategoryView addChildViewController:topView];
}
UITabBarController *tabBarController = (UITabBarController
*)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3];
UITabBarItem *tabBarItem5 = [tabBar.items objectAtIndex:4];
[tabBarItem1 setFinishedSelectedImage:[UIImage
imageNamed:@"ranking2.png"] withFinishedUnselectedImage:[UIImage
imageNamed:@"ranking1.png"]];
[tabBarItem2 setFinishedSelectedImage:[UIImage
imageNamed:@"ichiran2.png"] withFinishedUnselectedImage:[UIImage
imageNamed:@"ichiran1.png"]];
[tabBarItem3 setFinishedSelectedImage:[UIImage
imageNamed:@"okiniiri2.png"] withFinishedUnselectedImage:[UIImage
imageNamed:@"okiniiri1.png"]];
[tabBarItem4 setFinishedSelectedImage:[UIImage
imageNamed:@"jisho2.png"] withFinishedUnselectedImage:[UIImage
imageNamed:@"jisho1.png"]];
[tabBarItem5 setFinishedSelectedImage:[UIImage
imageNamed:@"settei2.png"] withFinishedUnselectedImage:[UIImage
imageNamed:@"settei1.png"]];
[self.tabBarController setDelegate:self];
[self.tabBarController setSelectedIndex:1];
[self.navRankingView setNavigationBarHidden:YES];
[self.navCategoryView setNavigationBarHidden:YES];
[self.navBookmarkView setNavigationBarHidden:YES];
[self.navDictionaryView setNavigationBarHidden:YES];
[self.navSettingsView setNavigationBarHidden:YES];
//If first run, generate settings plist. (IMPORTANT! DO NOT DELETE)
if (![KaomojiCommons checkIfSettingsPlistExists]) {
[KaomojiCommons generateInitialSettings];
}
//Generate Blank Database in Local Directory. (IMPORTANT! DO NOT DELETE)
if (![KaomojiSQLiteController checkIfDatabaseExists]) {
[KaomojiSQLiteController copyDatabase];
}
//Generate Kaomoji Group. (IMPORTANT! DO NOT DELETE)
if (![KaomojiCommons checkIfKaomojiGroupExistsInContacts]) {
[KaomojiCommons createKaomojiGroupInContacts];
}
[self.window makeKeyAndVisible];
return YES;
Can anyone tell me what I did wrong here?
No comments:
Post a Comment