iOS标签应用程序在切换标签时切换回iPhone 5上的iPhone 4分辨率

时间:2013-09-12 03:22:51

标签: iphone ios objective-c uitabbarcontroller

我有一个标签式应用程序,它在iPhone 5上有五个选项卡。每个将加载到每个选项卡的视图控制器都有一个单独的用于iPhone4和iPhone5的nib文件。

当应用程序在iPhone 5上加载时,第一页就可以了,这意味着它使用整个屏幕(320x568)。但是,当我切换标签时,它使用iPhone 4分辨率(320x480)。

以下是我的app app委托代码,位于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;

谁能告诉我这里做错了什么?

1 个答案:

答案 0 :(得分:0)

jettplaine ..

1.首先添加iPhone Retina(4英寸)和Retina(3.5英寸)图像作为发布图像。

添加名为Default-568h@2x.png的启动图像。这会将您的应用标识为支持iPhone 5指标的应用