界面控制器标题在 运行 时间内没有改变
Interface Controller Title not changing during run time
我试图在应用程序生命周期的某一时刻以编程方式更改我的 Interface Controller
的标题。
但是,当应用程序 运行 时,这似乎不起作用?这是故意的,一个错误,还是我做错了什么?
解释:
我设置它的方式是在 Storyboard 中使用标题 aa。然后在 awakeWithContext:
中,我检查 User Defaults
中的一个变量,它确定要为 Interface Controller
设置什么状态。在一种情况下,我将标题更改为 yy,在另一种情况下,我通过调用两种设置方法之一将其更改为 xx (setUpForShowing
/setUpForCreating
)。
在某个时刻,用户将按下一个按钮,该按钮会显示 modal view
。就在显示该视图之前,我调用了相反的设置方法,更改了 Interface Controller
的状态。屏幕上的所有内容都已正确更改,因此我知道调用了正确的方法。但是,标题 不会更新 。
有没有人经历过类似的事情?
documentation 状态:
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.
尝试使用setTitle:
方法在willActivate
中设置标题。
我试图在应用程序生命周期的某一时刻以编程方式更改我的 Interface Controller
的标题。
但是,当应用程序 运行 时,这似乎不起作用?这是故意的,一个错误,还是我做错了什么?
解释:
我设置它的方式是在 Storyboard 中使用标题 aa。然后在 awakeWithContext:
中,我检查 User Defaults
中的一个变量,它确定要为 Interface Controller
设置什么状态。在一种情况下,我将标题更改为 yy,在另一种情况下,我通过调用两种设置方法之一将其更改为 xx (setUpForShowing
/setUpForCreating
)。
在某个时刻,用户将按下一个按钮,该按钮会显示 modal view
。就在显示该视图之前,我调用了相反的设置方法,更改了 Interface Controller
的状态。屏幕上的所有内容都已正确更改,因此我知道调用了正确的方法。但是,标题 不会更新 。
有没有人经历过类似的事情?
documentation 状态:
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.
尝试使用setTitle:
方法在willActivate
中设置标题。