gpt4 book ai didi

swift 3 : I can't hide the back button

转载 作者:搜寻专家 更新时间:2023-11-01 06:02:37 24 4
gpt4 key购买 nike

我正在使用 Tab Bar Controller,上面有 2 个 View Controller 。在此之前,我有另一个 viewController 来访问标签栏。当我得到标签栏时,后退按钮总是消失。我想隐藏后退按钮,用另一个按钮作为左键,但我无法隐藏后退按钮。

这是 Tab Bar 之前的 viewController 中的代码:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "mainvc"{
if pinLabel.text == pinPassword && pinLabel.text != ""{
let tabBarController = segue.destination as! UITabBarController
let destinationViewController = tabBarController.viewControllers?[0] as! ViewController

destinationViewController.login.email = login.email
destinationViewController.login.firstname = login.firstname
destinationViewController.login.lastname = login.lastname
destinationViewController.login.imageURL = login.imageURL
destinationViewController.login.id = login.id
}else{

}

}
}

这是我试图隐藏后退按钮并将另一个按钮放入其中一个 View Controller 的代码,这是我在访问选项卡栏 Controller 时看到的 View Controller :

let leftOpenSideBarMenu: UIBarButtonItem = UIBarButtonItem(image: myimage, style: .plain, target: self, action: #selector(ViewController.openSideBarMenu))
self.navigationItem.setHidesBackButton(true, animated: false)
self.navigationItem.setLeftBarButtonItems([leftOpenSideBarMenu], animated: true)

最佳答案

尝试

self.tabBarController.navigationItem.setHidesBackButton(true, animated: false)
self.tabBarController.navigationItem.setLeftBarButtonItems([leftOpenSideBarMenu], animated: true)

代替

self.navigationItem.setHidesBackButton(true, animated: false)
self.navigationItem.setLeftBarButtonItems([leftOpenSideBarMenu], animated: true)

关于 swift 3 : I can't hide the back button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45165190/

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