如何关闭tabbar swift
我有一个登录视图控制器,在正确登录时,它将使用以下方法打开tabbar控制器:如何关闭tabbar swift,swift,uitabbarcontroller,uitabbar,Swift,Uitabbarcontroller,Uitabbar,我有一个登录视图控制器,在正确登录时,它将使用以下方法打开tabbar控制器: self.dismissViewControllerAnimated(true, completion: { self.loadHomeScreen()}) func loadHomeScreen() { emailField.text = "" passwordField.text = "" self.presentViewController(UISto
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
}
}
我想我的登录视图控制器仍在后台?我在选项卡组的每个导航栏上都有一个注销按钮作为rightbarbutton项。我希望能够关闭此按钮按下时的选项卡栏。我怎样才能做到这一点。我找不到任何例子。我会使用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)
}
@DharmeshKheni和我的tabgroup不会在后台占用内存?@DharmeshKheni如何在swift中关闭当前的viewController?@DharmeshKheni ok,这与我丢失的活动警报略有不同。按照你的方法,我的应用程序因一个未知的NSException类型异常而崩溃。更新问题以显示我的code@DharmeshKhenidismissViewControllerAnimated(true,completion:nil)正在解除视图控制器,但我需要解除选项卡栏控制器。这就是问题所在吗?