简体   繁体   English

多个故事板 - 多个导航控制器

[英]Multiple Storyboards - Multiple Navigation Controllers

I am breaking up my project into multiple storyboards. 我将我的项目分解为多个故事板。 I have a login storyboard with a navigation controller. 我有一个带导航控制器的登录故事板。 The last step "Complete Registration" takes you to main.storyboard . 最后一步“完成注册”将您带到main.storyboard

This leaves the navigation controller in place, and the back button takes you back to register. 这使导航控制器保持原位,后退按钮将您带回注册。 I obviously don't want that. 我显然不希望这样。 I know I can hide the bar by using: 我知道我可以使用以下方法隐藏栏:

self.navigationController?.navigationBarHidden = true

But how can I leave the navigation controller? 但是我怎么能离开导航控制器呢?

Any help would be greatly appreciated! 任何帮助将不胜感激!

The easiest and most correct way to do this would be to make your login screen a modal view. 最简单和最正确的方法是使您的登录屏幕成为模态视图。 If you don't want to give your user the ability to go back, then you shouldn't use a push segue. 如果您不想让用户返回,那么您不应该使用push segue。 You should use a modal view. 您应该使用模态视图。

In the iOS Human Interface guidelines it says that modal views should be used for "a self-contained task [that] must be completed—or explicitly abandoned—to avoid leaving the user's data in an ambiguous state." 在iOS人机界面指南中,它表示模态视图应该用于“必须完成或明确放弃的自包含任务 - 以避免将用户的数据置于模糊状态。”

A modal view will make it so your login and your main screen have to be in separate Navigation Controllers. 模态视图将使您的登录和主屏幕必须位于单独的导航控制器中。

In the completion handler of the "Complete Registration" action you'll want to use the following code. 在“完成注册”操作的完成处理程序中,您将需要使用以下代码。

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateInitialViewController() as! (TypeOfViewController)
        self.presentViewController(viewController, animated: true, completion: nil)

If your main.storyboard is already embedded in a NavigationController (Initial view controller is a UINavigationController) then you'll have to do that a little bit differently. 如果你的main.storyboard已经嵌入在NavigationController中(初始视图控制器是一个UINavigationController),那么你必须以不同的方式做到这一点。

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateInitialViewController()
        self.presentViewController(viewController, animated: true, completion: nil)

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

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