- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissViewControllerAnimated:YES completion:^{}];
[self.navigationController.tabBarController.view addSubview:self.waitingView];
dispatch_queue_t currentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(currentQueue, ^{
self.originalImgFromPicker = [info objectForKey:UIImagePickerControllerOriginalImage];
CGSize size = self.originalImgFromPicker.size;
if (size.width > 320)
{
size.height /= (size.width / 320);
size.width = 320;
}
UIGraphicsBeginImageContext(size);
[self.originalImgFromPicker drawInRect:CGRectMake(0,0,size.width,size.height)];
self.resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.originalImgFromPicker = nil;
NSData *resizedImageBinary = UIImageJPEGRepresentation(self.resizedImage, 1.0);
self.resizedImageBinaryString = [NSString base64StringFromData:resizedImageBinary length:resizedImageBinary.length];
dispatch_sync(currentQueue, ^{
[self.waitingView removeFromSuperview];
});
});
}
我正在处理图像,在此期间,我使用带有活动指示器的透明视图来阻止 UI。
但是这种self.waitingView
消失需要很长时间才应该。
当图像处理正在进行时,self.waitingView
当我尝试点击没有任何工作的控件但当异步块中的图像处理完成self.waitingView
时仍然保留在屏幕上并且当我尝试点击任何控件时它会响应时,UI实际上会被阻塞。
如果我什么都不做,它需要一些时间才能消失。
我想以活泼的方式做到这一点,我在代码中做错了什么?