2

在我的应用程序中,许多视图控制器都有一个容器视图,其中包含一种“仪表板”,在整个应用程序中共享多个按钮和标签。在两个视图控制器之间进行 segue 时,通常会发生以下情况:

1) the new view controller's viewDidLoad is called;
2) the new view controller's viewWillAppear is called;
3) the dashboard's viewDidLoad is called (there is an automatic segue to it, since it's inside a Container View);
4) the dashboard's viewWillAppear is called;

现在,在仪表板的 viewWillAppear 方法中,我对不同的标签进行了一些格式化(更改它们的文本和颜色)。但是,在 iOS 8.3 中,这似乎没有效果。例如,我执行以下操作来更改按钮的标签:

self.myButton.titleLabel.text = @"myText";

然而,在这条指令执行之后,做一个

(lldb) po self.myButton.titleLabel.text

在调试器提示符处,将输出该按钮标签的先前内容(来自情节提要)而不是“myText”。不用说,在 iOS 8.2(包括 iOS 7)之前一切正常。

所以我的问题是:在 iOS 8.3 的视图/segue 生命周期级别有什么改变吗?

4

1 回答 1

0

您必须使用[myButton setTitle:forState:]来更改按钮的标题。如果它以前有效,那纯属运气。

于 2015-04-22T21:09:49.630 回答