簡體   English   中英

切換標簽頁時,iOS Tabbed應用程序會切換回iPhone 5上的iPhone 4分辨率

[英]iOS Tabbed Application switches back to iPhone 4 resolution on iPhone 5 when switching tabs

我有一個選項卡式應用程序,該應用程序在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;

誰能告訴我我在這里做錯了什么?

傑普特萊恩..

1.首先添加添加的iPhone Retina(4英寸)和Retina(3.5英寸)圖像作為啟動圖像。

添加一個名為Default-568h@2x.png的啟動圖像。 這將確定您的應用程序是否支持iPhone 5指標

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM