How to add an indicator to UIImagePickerController

I have an image picker to select multiple images from a photo library. The selected photos are modified and saved in the imagePickerController:didFinishPickingMediaWithInfo: file. It takes a few seconds.

Can I put an indicator in a view? I tried using the addSubview:indicatorView method in imagePickerController:didFinishPickingMediaWithInfo: But the View indicator does not appear. It is rejected using imagePickerView.

+4
source share
1 answer

You must add a UIActivityIndicatorView at the top of the view hierarchy or it will be rejected using the UIPickerViewController if you do not use the callback after the resize operation and you reject the UIImagePickerController in the callback.

Or you could use HUD progress as SVProgressHUD .

Hope this helps =)

We did a short chat session and decided like this:

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_main_queue(), ^{ UIView *primaryImage = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,460)]; primaryImage.backgroundColor = [UIColor redColor]; primaryImage.alpha =0.9; UIView *secondaryImage = [[UIView alloc] initWithFrame:CGRectMake(0,0,70,70)]; secondaryImage.center = CGPointMake(160, 240); secondaryImage.backgroundColor = [UIColor blackColor]; secondaryImage.alpha = 0.9; secondaryImage.layer.cornerRadius = 12; [primaryImage addSubview:secondaryImage]; UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 25, 25)]; indicator.center = CGPointMake(35, 35); [indicator setHidesWhenStopped:NO]; [secondaryImage addSubview:indicator]; [indicator startAnimating]; [indicator release]; [secondaryImage release]; [picker.view addSubview:primaryImage]; [primaryImage release]; }); // Put here the code to resize the image dispatch_async(dispatch_get_main_queue(), ^{ // Dismiss the picker controller }); }); 
+3
source

Source: https://habr.com/ru/post/1412253/


All Articles