我希望你能帮助我。我不知道我做错了什么,我已经为代码完成了很多圈。我尝试的是,当用户通过身份验证时,它会被重定向到tabcontroller,但视图不会加载(黑屏加载)。奇怪的是它加载了黑色加载视图中的顶层菜单。故事板的附加图像和假定的加载视图。非常感谢你
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) }
答案 0 :(得分:0)
问题是你没有在TabBarViewController中设置viewController。使用Below方法在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()
}