Iphone - DismissModalViewControllerAnimated within imagePickerController
Lets say I have a controller class A which implements UIImagePickerControllerDelegate.
within A , I implement the delegate like this :
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[self 开发者_StackOverflow中文版dismissModalViewControllerAnimated:YES];
}
Who will get dismissed here ? the imagePickerController or A ? please explain why...
Calling presentModalViewController:animated:
on a UIViewController
will display a view controller modally. By analogy, dismissModalViewControllerAnimated:
dismisses the modal view controller. In this case, it would dismiss the image picker controller (Assuming the image picker controller is the modal view of the object that is its delegate, which is most likely the case).
The UIImagePickerController will get dismissed.Here is the documentation
The parent view controller is responsible for dismissing the modal view controller it presented using the presentModalViewController:animated: method. If you call this method on the modal view controller itself, however, the modal view controller automatically forwards the message to its parent view controller.
You Try this is working for me
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[picker dismissModalViewControllerAnimated:YES];
}
cheeers..
精彩评论