【问题标题】:UIButton setTitle doesn't change title immediatelyUIButton setTitle 不会立即更改标题
【发布时间】:2014-07-02 13:15:12
【问题描述】:

我在书写和阅读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] 有可能被异步调用吗?如果是,是否有可能使此调用同步?

【问题讨论】:

    标签: ios objective-c asynchronous uibutton


    【解决方案1】:

    您可能想要currentTitle 而不是titleLabel.text。或者titleForState:UIControlStateNormal。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多