gpt4 book ai didi

ios - 在 UITabBarController 的 tabBar 前面呈现 ViewController 并隐藏这个 tabBar

转载 作者:IT王子 更新时间:2023-10-29 05:45:59 28 4
gpt4 key购买 nike

在我的项目中,我有一个 UITabBarController。在其中一个 ViewControllers 上我有一个按钮。当我单击此按钮时,一个新的 ViewController 将以模态方式呈现。

问题是,当第二个 VC 呈现时,tabBarControllertabBar 仍然可见。当我尝试使用此方法将其隐藏在第一个 ViewController 的操作 openFiltersList() 中时:

self.tabBarController?.tabBar.hidden = true

它隐藏了,但是当我试图取消隐藏它时,当我关闭第二个 VC 时,将此参数设置为 false 不起作用,tabBar 保持隐藏状态。这是第一个和第二个的代码:

首先(InvitesViewController,tabBarController 的 View Controller 之一):

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

}

我正在使用 Storyboard作为界面。

最佳答案

您应该从标签栏 Controller 中呈现新的 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)

})

}

关于ios - 在 UITabBarController 的 tabBar 前面呈现 ViewController 并隐藏这个 tabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31297754/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com