导航项目标题问题

时间:2016-01-18 16:36:47

标签: ios swift uinavigationcontroller uinavigationitem

我有一个UITabBarController与一个与UITableView相关的UINavigationController连接,最后与UIViewController连接。 我已使用该代码以编程方式将UITableViewUIDetailViewController连接:

...
navigationController?.pushViewController(detail!, animated: true)

在我的UIDetailViewController中,如果我尝试更改那样的navigationItem.title:

self.navigationController!.navigationItem.title = "Hello"

什么都没发生。导航项不会更改标题。

1 个答案:

答案 0 :(得分:0)

您可以使用以下命令更改navigationItem标题的标题: -

self.navigationItem.title =" YourTitle";

或其他方式是: -

在UIDetailViewController中编写以下代码行:

override func viewDidLoad()   
{            
    super.viewDidLoad()
    self.title = "ok"
}