タブコントローラーが表示されない

実現したいこと

タブコントローラーを使ったアプリを実装しています。

発生している問題・分からないこと

タブコントローラーをストリーボード上で追加するもビルドすると表示されません。
(実機も同じくです。)

エラーメッセージ

error

1エラーメッセーは出ていません。

該当のソースコード

Swift

1// SceneDelegate.swift2 3import UIKit4import Firebase5 6class SceneDelegate: UIResponder, UIWindowSceneDelegate {7 8 var window: UIWindow?9 10 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {11 guard let windowScene = (scene as? UIWindowScene) else { return }12 self.window = UIWindow(windowScene: windowScene)13 14 // アプリケーション起動時にログイン状態を確認する15 self.checkLoginStatus()16 }17 18 func sceneDidDisconnect(_ scene: UIScene) {19 // Called as the scene is being released by the system.20 // This occurs shortly after the scene enters the background, or when its session is discarded.21 // Release any resources associated with this scene that can be re-created the next time the scene connects.22 // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).23 }24 25 // 以下のメソッドは割愛26 27 // ログイン状態をチェックする28 func checkLoginStatus() {29 // 現在のユーザーを取得30 let user = Auth.auth().currentUser 31 // ユーザーがログインしている場合32 if user != nil {33 // タブコントローラーを作成34 let storyboard = UIStoryboard(name: "Main", bundle: nil)35 let tabBarController = storyboard.instantiateInitialViewController() as! UITabBarController36 37 // MainViewControllerを取得して設定38 let MainViewController = storyboard.instantiateViewController(withIdentifier: "Main") as! MainViewController39 tabBarController.viewControllers = [MainViewController]40 41 window?.rootViewController = tabBarController 42 } else {43 // ユーザーがログインしていない場合44 // 未ログインの場合はSubのストーリーボードへ画面遷移45 let storyboard = UIStoryboard(name: "Sub", bundle: nil)46 let viewController = storyboard.instantiateViewController(withIdentifier: "SubViewController")47 window?.rootViewController = viewController 48 }49 50 // UIWindowを表示する51 self.window?.makeKeyAndVisible()52 }53}54

試したこと・調べたこと

上記の詳細・結果

SceneDelegateで画面を分岐しています。
ログイン状態なら → Main
未ログイン状態なら → Sub
に画面遷移する仕様です。

Main側はTabControllerを導入しています。

// 画面構成
イメージ説明

// シュミレーター
イメージ説明

// ストーリーボード - Main
イメージ説明

✔️itemのtintColorは青(白 or 透明ではない)です。

補足

慣れていないのでお手柔らかにお願いいたします。

コメントを投稿

0 コメント