UIButton setTitle不会立即更改标题

时间:2014-07-02 13:15:13

标签: ios objective-c asynchronous uibutton

通过撰写和阅读UIButton的标题,我遇到了麻烦。

我的问题:

// If I execute this line of code everything works fine, the title gets changed in the UI
[self.lastButtonPressed setTitle:stringDate forState:UIControlStateNormal];

// In the next line of code I want to read the title I've set before, but everything I get is the title of the UIButton before I changed the title.
NSString *myText = [self.lastButtonPressed.titleLabel.text];

[UIButton setTitle]是否可能被异步调用?如果是,是否有可能使此呼叫同步?

1 个答案:

答案 0 :(得分:5)

您可能希望currentTitle不是titleLabel.text。或许titleForState:UIControlStateNormal