正在嘗試更新標籤,同時執行不同的任務。我搜索,用這種方式使用不同的選項和endup但它仍然無法正常工作:正在更新主線程上的標籤不起作用
[processStatusLable performSelectorOnMainThread:@selector(setText:) withObject:@"Creating your account..." waitUntilDone:NO];
DCConnector *dccon = [DCConnector new];
ContactsConnector *conCon = [ContactsConnector new];
if (![dccon existUsersData]) {
[dccon saveUsersInformation:device :usDTO];
//created account
//get friends -> Server call
[processStatusLable performSelectorOnMainThread:@selector(setText:) withObject:@"Checking for friends..." waitUntilDone:NO];
NSMutableArray *array = [conCon getAllContactsOnPhone];
// save friends
[processStatusLable performSelectorOnMainThread:@selector(setText:) withObject:@"Saving friends.." waitUntilDone:NO];
if ([dccon saveContacts:array]) {
[processStatusLable performSelectorOnMainThread:@selector(setText:) withObject:@"Friends saved successfully.." waitUntilDone:NO];
}
}
是越來越執行的最後performSelector
(至少我看到標籤上的文字改變視圖),但所有其他選擇沒有工作。任何想法爲什麼?
編輯1
- (void)updateLabelText:(NSString *)newText {
processStatusLable.text = newText;
}
嘗試waitUntilDone:是的,如果你可以上傳你從@selector調用的方法,那將是非常棒的... – 2013-05-01 15:22:04
也許它在UILabel中顯示,但它變化太快? – 2013-05-01 15:24:36
它不應該這個過程需要像一分鐘 – SaifDeen 2013-05-01 15:26:09