0

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

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

下面是我的代码,位于我的应用程序委托中,在 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;

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

4

1 回答 1

0

喷气式飞机..

1.首先添加添加iPhone Retina(4英寸)和Retina(3.5英寸)图像作为启动图像..

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

于 2013-09-12T05:40:30.540 回答