1

翻訳はかなり簡単なので、swiftとobjective-cの両方で回答を受け入れます。

スプラッシュ スクリーン付きのタブ バーを表示したいのですが、そのスプラッシュ スクリーンをタブ バーの項目に表示して選択したくありません。

私のセットアップ (以下) では、タブ バーが表示されたときに最初に表示されるコントローラーとしてランディング スクリーンが表示されます。ただし、そのタブバーの項目を非表示にしたいです。ユーザーが選択できるのは、他の 3 つのタブのみです。どうすればいいですか?

//Create and add landing view
        navigation = UINavigationController()
        landingView = WGMLandingViewController(nibName: XIBFiles.LANDINGVIEW, bundle: nil)
        navigation.pushViewController(landingView, animated: false)
        navigation.title = "Landing View"
        controllers.append(navigation)

        //Create and add library view
        navigation = UINavigationController()
        libraryView = WGMLibraryViewController(nibName: XIBFiles.LIBRARYVIEW, bundle: nil)
        navigation.pushViewController(libraryView, animated: false)
        navigation.title = "Learn More"
        controllers.append(navigation)

        //Create and add pad view
        navigation = UINavigationController()
        orderPadView = WGMOrderPadViewController(nibName: XIBFiles.ORDERPADVIEW, bundle: nil)
        navigation.pushViewController(orderPadView, animated: false)
        navigation.title = "Order Pad"
        controllers.append(navigation)

        //Create and add lookup view
        navigation = UINavigationController()
        partLookupView = WGMLookupViewController(nibName: XIBFiles.LOOKUPVIEW, bundle: nil)
        navigation.pushViewController(lookupView, animated: false)
        navigation.title = "Lookup"
        controllers.append(navigation)

        //Set up controller list
        self.setViewControllers(controllers, animated: false)
4

1 に答える 1

0

Apple の既存の API ではこれを行うことはできませんが、サブクラス化して目的の処理を実行するのはそれほど難しくありませUITabBarControllerん。

わかりました..私の元の答えは最近うまくいきません..または私は老人になり、それはうまくいきませんでした、そして私は何か他のことをしました. *咳*

とにかく、独自のタブ バー コントローラーをロールする必要があります。コンテインメント ビュー コントローラーがあり、UITabBar.

  1. UIViewController(タブ バー コントローラー) を作成し、その中に aUITabBarと aを貼りUIView付けます。
  2. ビュー用のアウトレットを作成します (これは、ビュー コントローラーが移動する場所です) およびタブ バー
  3. UITabBar好きなように構成します。
  4. delegateUITabBarをビュー コントローラに設定し、didSelectItemメソッドを実装します。
  5. スプラッシュ スクリーン ビュー コントローラーをロードし、必要な場所に貼り付けるメソッドを作成しますviewDidLoad

何かのようなもの

 - (void)loadSplashScreen  {
    // load in the child view controller
    UIViewController *splashScreenController = ...;
    [self loadChildViewController:splashScreenController];

    // make sure nothing in the tab bar is selected
    self.tabBar.selectedItem = nil;
}

次に、さまざまなタブが選択されるたびに適切なView Controllerをロードするコードも追加します

 - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    // logic to figure out which view controller you want based on `item`
    // ...

    UIViewController = ...;
    [self loadChildViewController:viewController];
}

- (void)loadChildViewController:(UIViewController *)viewController {
    [self removeCurrentTabController]; // remove the existing one, if any using whatever memory management techniques you want to put in place.

    [self addChildViewController:viewController];
    [self.tabView addSubview:viewController.view];  // where self.tabView is your outlet from step 2.
}
于 2014-09-04T16:45:09.403 に答える