在buttonClicked方法中,我想將UILabel中的文本顏色設置爲黑色,等待三秒鐘,然後將顏色設置爲綠色。但是,標籤永遠不會變黑。該方法等待三秒鐘,然後UILabel文本變爲綠色。我認爲使用performSelectorOnMainThread會解決這個問題,但它沒有。代碼如下。非常感謝,如果我錯過了一些明顯的事情,我很抱歉。IOS buttonClick並更新視圖
喬恩R.
-(void) buttonClicked: (id) sender
{
// (UILabel *) letterLabel is instance variable of TestProgramDelegate
[letterlabel performSelectorOnMainThread:@selector(setTextColor:) withObject:[UIColor blackColor] waitUntilDone:YES];
[NSThread sleepForTimeInterval:3];
[letterLabel performSelectorOnMainThread:@selector(setTextColor:) withObject: [UIColor greenColor] waitUntilDone:YES];
}
你最終解決了這個問題嗎? – bryanmac