我在 swift 3 中有下一个结构:
导航 Controller -> 标签栏 Controller -> 4 个 View Controller
我有 3 个公共(public)栏按钮项目。 我的问题是,在其中一个 View Controller 中,我想在右上角添加新的栏按钮项。这样,当我导航到其他 View 时,新按钮就不会出现。
我该如何解决这个问题?
谢谢!
最佳答案
你应该在 Swift 中用 tabBarController 设置它:
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "imageName"), for: .normal)
button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
let leftButtonBar = UIBarButtonItem(customView: button)
tabBarController?.navigationItem.rightBarButtonItems = [leftButtonBar].
这是永远的最佳答案,并且可以正常工作。
关于ios - 使用选项卡栏 Controller Swift 在导航栏中添加新的栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43605501/