在快速选项卡式应用程序中以模块化方式显示登录视图控制器

时间:2018-10-03 19:38:03

标签: swift appdelegate modalviewcontroller presentmodalviewcontroller presentviewcontroller

我正在尝试从我的应用程序委托中模态地呈现视图控制器,但是,我收到以下错误。创建项目时,我选择了选项卡式应用程序。我需要帮助解决此错误并提出视图控制器。也希望代码能消除视图控制器

2018-10-03 20:28:57.324 App[74397:2825933] Warning: Attempt to present <App.SignUpViewController: 0x7fbd7b608c60> on <UITabBarController: 0x7fbd7b407620> whose view is not in the window hierarchy!

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    showSignUpView()
    return true
}

func showSignUpView() {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let signUpViewController = storyboard.instantiateViewController(withIdentifier:"SignUpViewController") as! SignUpViewController
    signUpViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
    signUpViewController.modalTransitionStyle = UIModalTransitionStyle.coverVertical
    window?.rootViewController?.present(signUpViewController, animated: true, completion: nil)
    }

0 个答案:

没有答案