我正在爲iPhone開發應用程序。我的問題是如何每0.5秒顯示一個不同文本的新標籤。例如,它會顯示藍色,紅色,綠色,橙色和紫色;一個接一個。現在我正在這樣做:標籤顯示不能與iPhone應用程序即時通訊
results = aDictionary;
NSArray *myKeys = [results allKeys];
NSArray *sortedKeys = [myKey sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
int keyCount = [sortedKeys count];
while (flag == NO) {
NSTimeInterval timeMS = [startDate timeIntervalSinceNow] * -10000.0;
if (timeMS >= i) {
ii++;
i += 1000;
NSLog(@"endDate = %f", timeMS);
int randomNumber = rand() % keyCount + 1;
lblResult.text = [results valueForKey:[sortedKeys objectAtIndex:(randomNumber - 1)]];
result = [results valueForKey:[sortedKeys objectAtIndex:(randomNumber - 1)]];
lblResult.text = result;
}
if (ii > 25) {
flag = YES;
}
}
lblResult.text = [results valueForKey:[sortedKeys objectAtIndex:(sortedKeys.count - 1)]];
此函數在viewDidAppear函數中調用,並且當前不顯示新標籤。它只顯示最後一個。我做錯了什麼?什麼是最好的方法來解決這個問題?
[中的中間爲()循環更新的UILabel]的可能重複(http://stackoverflow.com/問題/ 6363828 /更新 - 用於循環的中間的uilabel) – 2011-06-17 00:59:54
另外[動態更新UILabel](http://stackoverflow.com/questions/6336991/dynamically-updating-a-uilabel )和[文本字段等待,直到循環結束更新](http://stackoverflow.com/questio ns/5829977 /)和[更改標籤文本的循環](http://stackoverflow.com/questions/6325202/objective-c-loop-to-change-label-text)和[調用睡眠和更新文本字段不起作用](http://stackoverflow.com/questions/5834062/calling-sleep5-and-updating-text-field-not-working) – 2011-06-17 01:01:16