我似乎无法让任何按钮出现在我的导航栏中。
流程:Navigation Controller -> Tab bar Controller -> ViewController(想把按钮放在这里)
我尝试在 ViewDidLoad 中以编程方式添加它:
let navigationBar = navigationController!.navigationBar
navigationBar.tintColor = UIColor.blackColor()
let leftButton = UIBarButtonItem(title: "Left Button", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
let rightButton = UIBarButtonItem(title: "Right Button", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
navigationItem.leftBarButtonItem = leftButton
navigationItem.rightBarButtonItem = rightButton
我也尝试过使用 Storyboard添加它,但它在运行时不显示。知道为什么我不能让按钮出现在导航栏中
最佳答案
试试这样:
self.tabBarController?.navigationItem.leftBarButtonItems = [leftButton]
关于ios - 标签栏 UIViewController 中导航栏中的按钮未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31747470/