我想更改 View 的导航标题,它与 Tab Bar Controller 相关,而 Tab Bar Controller 又与 Navigation Controller 相关(见图)
我不知道该怎么做。
对于基本 View ,我只需要在 ViewController.swift 中执行此操作:self.title="test"
但是在这里,这一行更改了标签栏的标题,但我想更改导航的标题。
最佳答案
在 Swift 3 上,在 UIViewController 中覆盖您的 viewDidAppear 方法并添加以下代码片段:
if let tabController = self.parent as? UITabBarController {
tabController.navigationItem.title = "My Title"
}
关于ios - swift 2 : Change navigation title on a view related to a Tab Bar Controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35565508/