views:

1191

answers:

2

When Apple introduced version 3.0 of the iPhone OS the UIImagePickerController changed slighty: it no longer provides an activity or progress indicator after the user confirms a recently taken photo. In a nutshell, you now - take a picture, - decide it's ok and - hit the "Use" button and wait. There is no indication as to whether you have actually hit the "Use" button or not. Often, I hit it several times since I am unsure if I actually hit it or not. After a few seconds, you see the image or the image becomes available via delegate connections, e.g.

  • (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

My question is this: - How do I display an UIActivityIndicatorView right after the "Use" button is selected? Or, how to I insert my own code by intercepting the "Use" button callback? I've searched the web and expected many people to have the same problem but have not found a solution yet.

Thanks.

+1  A: 

Unfortunatly you cant intercept this call. I say this because there is no delegate method in UIImagePickerController that will tell the delegate about the push of Use button. Since you cant change the code in UIImagePickerController i dont think there is anything one can do. Apple mightimprove this with 3.1, i heard that they have done some work on UIImagePickerController...

Daniel
from what I was able to see from looking at the 3.1 api files you still can't, but that could all change Wednesday
Matt S.
A: 

What you can essentially do is add your UIActivityInidicatior to the UIImagePicker view before you dismiss it.

here is a similar thing I'm doing while I'm compressing the image after the user has pushed the use button. Notice the NSTimer - it's a nifty trick to cause the iphone to actually show the UI you're adding: on didFinishPickingImage:

//this will add the UIActivityInidicatior to the picker view

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { showActivity(@"Compressing Image", picker.view);

//this is a hack so the progress label will show up

[NSTimer scheduledTimerWithTimeInterval: 0.0f target: self selector: @selector(compress:) userInfo: image repeats: NO]; }

//the Compress method

(void) compress:(NSTimer *)inTimer { NSAutoreleasePool *_pool = [[NSAutoreleasePool alloc] init];

//do some work

[[self getPicker] dismissModalViewControllerAnimated:YES];

//dismiss the view we added to the picker showActivity(nil, [self getPicker].view);

[_pool release];

}

notice I keep the UIImagePickerController outside so I can reference it from the invoked message.

showActivity is a simple method that adds some ui to the given view.

//sorry for the color coding - the editor here is not doing such a good job.

Yosi Taguri
can you post your complete code? i'm also loking for such a similar thing
Rahul Vyas