ioswatchkitwkinterfacecontroller

Interface Controller Title not changing during run time


I'm trying to change the title of my Interface Controller programmatically at one point during the app's lifecycle.

However, this doesn't seem to be working when the app is running..? Is that intentional, a bug, or am I doing something wrong?

Explanation:

The way I've set it up is with a title aa in Storyboard. Then in awakeWithContext: I check for a variable in the User Defaults, which determines what state to set up the Interface Controller for. In one case I change the title to yy, in the other I change it to xx through calling one of two setup methods (setUpForShowing/setUpForCreating).

At some point the user will press a button, which displays a modal view. Right before that view is displayed, I call the opposite setup method, changing the state of the Interface Controller. Everything on the screen is changed correctly, so I know the correct method is called. However, the title does not update.

Have anyone experienced something similar?


Solution

  • The documentation states:

    An interface controller can make changes to its interface only during initialization and when the interface is active. Once the didDeactivate method is called, any attempts to change the value of related interface objects are ignored until the interface controller’s willActivate method is called again.

    Try to set the title in willActivate using the setTitle: method.