ranonk
ranonk

Reputation: 475

UIImagePicker and overlays

In my app, after an image is picked with uiimagepicker, it is processed via a webservice. The web processing takes a second, so I'd like to create an grayed out overlay with an activity indicator view.

My problem is that the UIImagePickerView view seems to stay on top of everything until the processing is finished.

I have tried using [myPicker dismissModalViewControllerAnimated:YES]; before the overlay is loaded or the processing even starts, but the view is still on screen. After that, my overlay is loaded as followed

ovController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:[NSBundle mainBundle]];

CGFloat yaxis = self.navigationController.navigationBar.frame.size.height;
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;

CGRect frame = CGRectMake(0, yaxis, width, height);
ovController.view.frame = frame;
ovController.view.backgroundColor = [UIColor grayColor];
ovController.view.alpha = 0.7;

[self.view insertSubview:ovController.view aboveSubview:self.view];

I have also tried using [[myPicker cameraOverlayView] insertSubview:ovController.view]; before I dismiss myPicker, but to no avail.

To be clear, I am trying bring the "loading" overlay on the screen after the UIImagePicker goes away, but before the web processing starts.

Any input will be appreciated. Thanks

Upvotes: 1

Views: 855

Answers (1)

dbslone
dbslone

Reputation: 2034

It sounds like you are doing the upload on the main thread which is locking the view from being updated. You might try doing the upload on a sperate thread so that the main thread can dismiss the image picker and display the overlay.

Upvotes: 1

Related Questions