我正在使用的应用程序中有一个功能,与其他操作相比,它有时需要相对较长的时间。我希望在函数执行时出现图像,以向用户显示应用程序仍在正常工作。
我认为可以做到的方式是:
_checkImpossibleImage.hidden = NO;
bool ratioIsPossible = [PaintGame isPossible:_paintChipRatio:_paintCanRatios];
_checkImpossibleImage.hidden = YES;
本质上,它会将图像设置为可见,执行函数,然后将图像设置为不可见。但是,在执行完本节中的所有代码之前,视图似乎不会更新。以下是整体功能:
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0){
// Do nothing (cancel option selected)
} else {
if (_buttonKey == @"New") {
_checkImpossibleImage.hidden = NO;
bool ratioIsPossible = [PaintGame isPossible:_paintChipRatio:_paintCanRatios];
_checkImpossibleImage.hidden = YES;
...
}
...
}
}
有没有办法强制更新当前视图,或者有没有更好的方法在函数执行时创建“加载”弹出窗口?