我有一个启动更新过程的UIAlertView。
UIAlertView询问用户他们是否想要更新。带线程的程序/方法流程
这里是我的代码:
- (void)reachabilityChanged:(NSNotification *)notification {
if ([connection isReachable]){
[updateLabel setText:@"Connection Active. Checking Update Status"];
[[[UIAlertView alloc] initWithTitle:@"Update Available" message:@"Your File Database is Out of Date. Would you like to Update?\nNote: Updates can take a long time depending on the required files." delegate:self cancelButtonTitle:@"Later" otherButtonTitles:@"Update Now", nil] show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {
[self updateFiles:[UpdateManager getUpdateFiles]];
}
}
上面的代码运行正常,但是,我updateFiles内:方法,我需要一些UI调整。
- (void)updateFiles:(NSArray *)filesList {
for (NSDictionary *file in filesList) {
[updateLabel setText:[NSString stringWithFormat:@"Downloading File: %@", [file objectForKey:@"Name"]]];
[UpdateManager updateFile:[file objectForKey:@"File Path"]];
}
[updateIndicator stopAnimating];
[updateLabel setText:@"Update Completed"];
}
的UIAlertView中并没有消除,直到在updateFiles方法语句运行后。
我无法让updateLabel显示当前正在下载的文件,尽管在更新过程结束时,我们在标签中获得了“更新完成”。
任何人都可以帮忙吗?
UPDATE
我开始怀疑这是更多数民众赞成被一些重同步过程耽误了进程。例如,我的[UpdateManager getUpdateFiles]
方法很繁重,涉及从网络获取资源。同样用我的[UpdateManager updateFile:[file objectForKey:@"File Path"]];
方法。
有什么办法可以强制UI更新优先于这些方法吗?
我只是想给用户一些反馈意见。