【发布时间】:2019-04-11 11:06:20
【问题描述】:
我浏览了一些在线教程,但没有任何效果。
这是我的 viewController 的代码:
import UIKit
class ViewController: UINavigationController {
let textView = UITextView()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// tried this
self.navigationItem.title = "AAA"
// and this
self.title = "AAA"
// and finally this
self.parent?.title = "AAA"
}
}
我不明白为什么这不起作用(我以前没有使用过导航栏)
我没有更改 main.storyboard 中的任何内容。
感谢您的回答。
【问题讨论】:
-
你确定你的 ViewController 嵌入了 NavigationController 吗?你的视图控制器类将是类 ViewController: UIViewController { }
-
那么如何添加导航栏。如果我使用 "class ViewController: UIViewController { } " 我不能使用 "self.navigationBar...."
标签: swift uikit uinavigationbar uinavigationitem