Hello,
Using Xcode9 and Swift4, I have a UIViewController that has a NavigationBar on it. I'm trying to dynamically update the navigation bar item title in prepareNavigationItem()
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareNavigationItem()
}
fileprivate func prepareNavigationItem() {
navigationItem.title = "My Title"
}
md5-90b1d12cc7977151746e7c50a4025cd8
/// Title text.
public var title: String? {
get {
return titleLabel.text
}
set(value) {
titleLabel.text = value
navigationItem.reload()
}
}
At the current moment I am not support Xcode 9 and Swift 4. That said, send me a project reproducing the issue, and I can take a look :)
Thanks, here's a demo project with the issue.
I spun up a new single view app project in Xcode9, added a UINavigationBar in the storyboard and changed the class to a NavigationBar (Material). Added the following code to the ViewController class
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepareNavigationItem()
}
fileprivate func prepareNavigationItem() {
navigationItem.title = "title"
}
For now you can use the following to set the title
navigationItem.titleLabel.text = "foo"
@a88zach Thank you :)
@james-ingold I will be preparing a branch for Swift 4 and Xcode 9 this week. At that point I will publish a solution to the issue. Thank you!
@danieldahan Excuse me Is there any branch swift4 supported?
Hey, checkout this commit https://github.com/CosmicMind/Material/commit/6b0bd134d458a1b3250985bf920cac952b799e9a from the development branch :)
Thanks :)
Most helpful comment
For now you can use the following to set the title
navigationItem.titleLabel.text = "foo"