簡體   English   中英

UIButton setTitle不會立即更改標題

[英]UIButton setTitle doesn't change title immediately

我在編寫和閱讀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]是否有可能被稱為異步方法? 如果是,是否有可能使此呼叫同步?

您可能需要currentTitle而不是titleLabel.text titleForState:UIControlStateNormal

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM