如何快速关闭tabbar

时间:2015-06-20 07:57:40

标签: swift uitabbarcontroller uitabbar

我有一个登录视图控制器,在正确的登录名下将使用以下方法打开标签栏控制器:

self.dismissViewControllerAnimated(true, completion: { self.loadHomeScreen()})

func loadHomeScreen()
    {
        emailField.text = ""
        passwordField.text = ""

        self.presentViewController(UIStoryboard.tabbarController()!, animated: true, completion: nil)
    }


private extension UIStoryboard {
        class func mainStoryboard() -> UIStoryboard { return UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) }

        class func tabbarController() -> UITabBarController? {
            return mainStoryboard().instantiateViewControllerWithIdentifier("TabbarControllerID") as? UITabBarController
        }
    }

我认为我的登录视图控制器仍在后台?我在选项卡组中的每个导航栏上都有一个注销按钮作为右栏按钮项。我希望能够关闭此按钮上的标签栏。我怎样才能做到这一点。我找不到任何例子。我会使用pop命令吗?

更新

@IBAction func tryLogout(sender: UIBarButtonItem) {
        self.dismissViewControllerAnimated(true, completion: nil)
        let storyboard = UIStoryboard(name: "main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier("login") as! UIViewController
        self.presentViewController(vc, animated: true, completion: nil)
    }

0 个答案:

没有答案