ios - 从 UINavigationController 堆栈转出到 UITabBarController

标签 ios objective-c iphone xcode swift

我有Login.storyboard:

enter image description here

登录 View Controller 有一个Segue到 Storyboard引用和 Storyboardmain.storyboard:

enter image description here

我的 LoginViewController 类代码有一个 TouchUpInside 操作处理程序,它以编程方式调用 main.storyboard 的 segue:

@IBAction func btnLoginTouchUpInside(sender: UIButton) {
        let params = AuthLoginParams(Username: txtFieldUsername.text!, Password: txtFieldPassword.text!)

        AuthLoginRequest.FetchUser(params) { (userModel) -> Void in
            if(userModel.IsAuthorized){
                self.performSegueWithIdentifier("mainStoryboardSegue", sender: nil)
            }else{

            }
        }
    }

现在让我们看看main.storyboard

enter image description here

因此,从 Login.storyboard -> 成功登录 segue -> Main.storyboard 我试图从 UINavigationController 中“退出”堆栈并使用 UITabBarController 开始新的/全新的操作。这是如果我使用 main.storyboard 启动应用程序并跳过 Login.storyboard 的屏幕截图: enter image description here

但是,如果我使用 Login.storyboard 启动我的应用程序,并尝试使用我的 segue 到 Stoyboard 引用 main.storyboardself.performSegueWithIdentifier("mainStoryboardSegue",发件人:无)

我仍然处于我不想要的登录过程 UINavBarController 堆栈中:

enter image description here

最佳答案

感谢@Paulw11在我的问题评论中的提示,他说我无法通过简单的segue来做我想做的事情,我必须以编程方式更改rootViewController,这是我想出的代码,包括过渡动画一切似乎都运行良好:

 let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
 let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("dashboardTabBarController") as! DashboardTabBarController

 UIView.transitionWithView(self.view.window!, duration: 0.5, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: {
                    UIApplication.sharedApplication().keyWindow?.rootViewController = viewController;
                    }, completion: nil)

关于ios - 从 UINavigationController 堆栈转出到 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35832330/

相关文章:

objective-c - "Expression is not assignable"-- 在 Xcode 中将 float 分配为其他两个 float 的总和时出现问题?

iphone - 导航栏标题图像问题

ios - UITableView 页眉和页脚高度与 Storyboard 布局不对应

iphone - 如何从 iOS 中已有的源代码创建静态库或框架

ios - 给 UIViewController 变量分配了多少内存

ios - 将文本字段输入更改为在 UIDatePicker 中选择的日期(当值更改时)

iphone - 我有 XML 喜欢遵循如何使用 touchXML 解析,我想为 <p231 :proNum>26400174350</p231:proNum> 获取像 26400174350 这样的数据

ios - UINavigationController 使用 SWRevealViewController 阻止 UITabBar

ios - NSForegroundAttributeName 不工作。文本填充呈现透明

ios - DOMException 105 仅在 UI 测试期间