Material: Ambiguous use of 'title' UINavigationItem

Created on 11 Aug 2017  路  7Comments  路  Source: CosmicMind/Material

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()
        }
    }
help wanted

Most helpful comment

For now you can use the following to set the title
navigationItem.titleLabel.text = "foo"

All 7 comments

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?

Thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Arkezis picture Arkezis  路  28Comments

MacMeDan picture MacMeDan  路  28Comments

OrkhanAlikhanov picture OrkhanAlikhanov  路  17Comments

ariedoelman picture ariedoelman  路  34Comments

sovata8 picture sovata8  路  15Comments