【发布时间】:2015-09-26 15:55:53
【问题描述】:
在我的项目中,我有一个UITabBarController。其中一个是ViewControllers 我有按钮。当我点击这个按钮时,一个新的ViewController 正在模态显示。
问题是,当第二个 VC 出现时,tabBarController 的 tabBar 仍然可见。当我尝试使用此方法将其隐藏在第一个ViewController 的操作openFiltersList() 中时:
self.tabBarController?.tabBar.hidden = true
它隐藏了,但是当我试图取消隐藏它时,当我关闭第二个 VC 时,将此参数设置为 false 不起作用,tabBar 保持隐藏状态。
这是第一个和第二个的代码:
首先(InvitesViewController,tabBarController 的视图控制器之一):
func openFiltersList() {
var filtersView : UIViewController = self.storyboard?.instantiateViewControllerWithIdentifier("filtersViewController") as! FiltersViewController
filtersView.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
self.presentViewController(filtersView, animated: true) { () -> Void in
UIView.animateWithDuration(0.3, animations: { () -> Void in
filtersView.view.backgroundColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 0.5)
})
}
self.tabBarController?.tabBar.hidden = true
}
第二个(FiltersViewController,没有嵌入任何地方):
@IBAction func dismiss(sender: AnyObject) { // close button action
self.dismissViewControllerAnimated(true, completion: nil)
var destinationVC : UIViewController = self.storyboard?.instantiateViewControllerWithIdentifier("invitesViewController") as! InvitesViewController
destinationVC.tabBarController?.tabBar.hidden = false
}
我正在使用故事板作为界面。
【问题讨论】:
-
您的模态视图是否嵌入在导航控制器中?
-
不,我的项目中没有任何导航控制器
-
@TheSD 我也在做同样的事情,并且模态视图嵌入在导航控制器中。你能指导我吗?
标签: ios swift uiviewcontroller uitabbarcontroller uitabbar