我正在尝试在不同的任务进行时更新标签。我搜索并使用了不同的选项并以这种方式结束,但它仍然不起作用:
[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;
}