简体   繁体   English

uiTabBarController视图中的黑屏

[英]Black screen in uiTabBarController view

I hope you can help me. 我希望你能帮助我。 I do not know what I am doing wrong and I have already done many laps to the code. 我不知道自己在做什么错,我已经对代码做了很多圈了。 What I try is that when the user is authenticated it is redirected to the tabcontroller, but the view does not load (black screen load). 我尝试的是,在对用户进行身份验证时,它将重定向到tabcontroller,但是视图不会加载(黑屏加载)。 The weird thing is that it loads the top menu in the black loading view. 奇怪的是,它在黑色加载视图中加载了顶部菜单。 Attached image of the Storyboard and the supposed loaded view. 情节提要的附加图像和假定的加载视图。 Thank you very much 非常感谢你

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 加载的视图

Problem is that you not set viewController in TabBarViewController. 问题是您没有在TabBarViewController中设置viewController。 Use Below method for show TabBarViewController in AppDelegate 使用下面的方法在AppDelegate显示TabBarViewController

 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()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM