简体   繁体   中英

Swift storyboard title won't change

I have a VC embedded in a Tab Bar Controller. The VC had the title "Profile" set in storyboard, and I changed this to "Menu". Now, in storyboard, the title shows as "Menu" - but when I run the project, it shows as "Profile". In the storyboard source, title="Menu" is set for the VC.

It happens to be the presenting storyboard, so I can change the title in viewWillAppear and it's resolved, but if I want to use a different storyboard as the presenting storyboard, it'll be an issue I'd rather not work around.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.title="Menu"
}

Where can I check besides the storyboard's title attribute to make sure this isn't still being set somewhere else, maybe somewhere that only has an effect at runtime. It's not being set in code anywhere

This question was identified as a duplicate of another question. However, my VC is embedded in a Tab Bar Controller, as stated in my first sentence, and I'm already using the code supplied in the answer to the suggested duplicate question in my code example. I wasn't trying to just get it to work, but to work the way it should

您可以尝试navigationItem.title = "Menu"

我实际上在main.strings中找到了它-在那里进行了更改,现在可以正确显示

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM