2017-06-10 16 views
0

私があなたを助けてくれることを願っています。私は何が間違っているのか分かりませんし、すでにコードに多くの周回を重ねています。私が試してみるのは、ユーザーが認証されると、タブコントローラーにリダイレクトされますが、ビューはロードされません(黒いスクリーンロード)。奇妙なことは、ブラックローディングビューでトップメニューをロードすることです。ストーリーボードの添付画像と想定されるロードビュー。問題は、あなたがTabBarViewControllerでのViewControllerを設定していないということですuiTabBarControllerビューの黒い画面

func application(_ application: UIApplication, 
    didFinishLaunchingWithOptions launchOptions: 
    [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 

    UIApplication.shared.statusBarStyle = .lightContent 

    let storyBoard: UIStoryboard = UIStoryboard(name:"Main", bundle: Bundle.main) 

    if Session.isLoggedIn { 
    print("User already logged In") 
    let tabBarController = storyBoard.instantiateViewController(withIdentifier: "TabBarBuyerController") 
    self.window?.makeKeyAndVisible() 
    self.window?.rootViewController = tabBarController 
    } else { 
    print("New User") 
    let loginViewController = storyBoard.instantiateViewController(withIdentifier: "LoginViewController") 
    self.window?.makeKeyAndVisible() 
    self.window?.rootViewController = loginViewController 
} 

    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) } 

Main StoryBooard picture

Loaded view

+0

私はInterface builderでSwftを使用している人にとってとても悪いと感じています。これのどれも今から10年前までは簡単にデバッグ可能になるでしょう。 objective-Cを使用し、プログラムでビューを作成すると、それを把握することができます – Loxx

答えて

0

ありがとうございました。 Show TabBarViewControllerのメソッドを下に使用AppDelegate

func showHeadlineTabBarViewController() { 

    let storyboard = UIStoryboard(name: "Main", bundle: nil) 

    let FirstViewController: UIViewController? = storyboard.instantiateViewController(withIdentifier: String(describing: FirstViewController.self)) 
    let FirstViewControllerNC = UINavigationController(rootViewController: FirstViewController!) 

    let secondViewController: UIViewController? = storyboard.instantiateViewController(withIdentifier: String(describing: SecondViewController.self)) 
    let secondViewControllerNC = UINavigationController(rootViewController: secondViewController!) 

    let tabBarController = storyBoard.instantiateViewController(withIdentifier: "TabBarBuyerController") 
    tabBarController.viewControllers = [FirstViewControllerNC, secondViewControllerNC] 

    window?.rootViewController = tabBarController 
    window?.makeKeyAndVisible() 
}