sách gpt4 ăn đã đi

ios - 如果通过 segue 从另一个选项卡进入,如何从 Controller 中删除 TabBar?

In lại Tác giả: Walker 123 更新时间:2023-11-30 12:17:47 25 4
mua khóa gpt4 giày nike

我正在使用一个包含 5 个选项卡的选项卡栏 Controller 。在 tab1 中,我有一个按钮可以将我带到 tab2。该 tab2 嵌入在导航 Controller 中。

那么当我通过segue从tab1来时,如何使Tab栏隐藏在tab2中?

在 Storyboard 中,我将Hide Bottom bar on Push激活。另外,我在 View 中编写了 self.tabBarController?.tabBar.isHidden = true 加载了 tab2。在tab1中我的prepareForSegue是这样的

  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

if segue.identifier == "ShortcutSegue" {

let tabVc = segue.destination as! UITabBarController
tabVc.selectedIndex = 1
tabVc.tabBarController?.tabBar.isHidden = true
}
}

câu trả lời hay nhất

对于 tab2 View Controller ,您可以编写以下代码来隐藏选项卡栏。

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let destinationTabBar = segue.destinationViewController as? UITabBarController {
if segue.identifier == "ShortcutSegue" {
destinationTabBar.viewControllers?.removeAtIndex(adminScreenIndex)
}
}
}

或者您可以在您的重写函数prepareForSegue 方法中编写以下代码。

if let tabVc = segue.destinationViewController as? tab2ViewController {
tabVc.hidesBottomBarWhenPushed = true
}

或者您可以在属性检查器的主 Storyboard 中为选项卡栏 View Controller 勾选“按下时隐藏按钮栏”,如下图所示。

Main storyboard attribute inspector "Hide Button Bar On Push"

关于ios - 如果通过 segue 从另一个选项卡进入,如何从 Controller 中删除 TabBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45194521/

25 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress