van*_*rov 9 uitabbarcontroller uiviewcontroller uitabbar ios swift
在我的项目中,我有一个UITabBarController.其中一个ViewControllers我有按钮.当我单击此按钮时,一个新ViewController的模态呈现.
问题是,当第二VC正在呈现,tabBarController的tabBar仍是可见的.当我尝试使用此方法在第一个ViewController动作中隐藏它时openFiltersList():
self.tabBarController?.tabBar.hidden = true
它隐藏了,但当我试图取消隐藏它时,当我解除第二个VC时,将此参数设置为false不起作用,tabBar保持隐藏状态.这是第一个和第二个的代码:
首先(InvitesViewController,tabBarController的View控制器之一):
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
    }
我正在使用故事板进行界面.
Dig*_*DEV 29
您应该从选项卡栏控制器中显示新的viewController:
 self.tabBarController?.presentViewController(filtersView, animated: true) { () -> Void in
        UIView.animateWithDuration(0.3, animations: { () -> Void in
            filtersView.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
        })
    }
在斯威夫特 5 中,
let popupController = ViewController()
popupController.modalPresentationStyle = .overFullScreen
self.present(popupController, animated: true, completion: nil)
| 归档时间: | 
 | 
| 查看次数: | 14470 次 | 
| 最近记录: |