我想禁用 iPad 的 UI 交互,直到使用 Blocks 在后端的主线程上下载数据
我正在加载时下载图像
-(void)downLoadImageData{
[self ShowActivityIndicator];
[iOSNetwork getImages:ImageID andEvent:eventID
onCompletion:^(NSString* result,NSError* error)
{
dispatch_async(dispatch_get_main_queue(), ^{
if(error)
{
[self stopFetch:@"Error while Processing"];
}
else
{
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[self stopFetch:result];
}
});
}];
}
-(void) stopFetch:(NSString*) result{
[self hideActivityIndicator];
//after downloading completed
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}
最佳答案
如果使用整个应用程序调用
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
下载完成后
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
另一种选择
[self.view setUserInteractionEnabled:NO];
完成后
[self.view setUserInteractionEnabled:YES];
多一个选择
self.navigationController.navigationBar.userInteractionEnabled=NO;
// perform other events also userInteractionEnabled=NO;
完成后
self.navigationController.navigationBar.userInteractionEnabled=YES;
// perform other events also userInteractionEnabled=NO;
在你的问题中
-(void)downLoadImageData{
[self ShowActivityIndicator];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents]; // call here
[iOSNetwork getImages:ImageID andEvent:eventID
onCompletion:^(NSString* result,NSError* error)
{
dispatch_async(dispatch_get_main_queue(), ^{
if(error)
{
[self stopFetch:@"Error while Processing"];
}
else
{
[self stopFetch:result];
// not here
}
});
}];
}
关于ios - 禁用 iPad 的 UI 交互,直到数据在后端的主线程上下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26857823/