iOS 8 Swift navigation bar title, buttons not showing in tab based application

前端 未结 3 2218
长情又很酷
长情又很酷 2021-02-10 11:34

I am trying to follow this tutorial, this answer, and this answer to create navigation bars for each of my tabs in a tab-based application in iOS 8 / Swift, but no title or butt

3条回答
  •  [愿得一人]
    2021-02-10 11:58

    No need to use a new navigation bar just use your existent navigation bar. Remember what you did here :

    let nc1 = UINavigationController(rootViewController: vc1)
    

    So your view controller is already embed inside a navigation controller just use self to access to the navigation items

    self.title = "Your Title"
    
    var homeButton = UIBarButtonItem(title: "LeftButton", style: .Plain, target: self, action: "")
    
    var logButton = UIBarButtonItem(title: "RigthButton", style: .Plain, target: self, action: "")
    
    self.navigationItem.leftBarButtonItem = homeButton
    self.navigationItem.rightBarButtonItem = logButton
    

提交回复
热议问题