如何在iPad上解雇UIImagePickerController

时间:2015-08-12 14:07:05

标签: ios ipad uiimagepickercontroller

我使用的是UIImagePickerController

UIImagePickerController *picker = [[UIImagePickerController alloc] init];    
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromRect:CGRectMake(0, 10, 500, 500) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

当我使用来自图库类的任何照片时,会调用委托didFinishPickingMediaWithInfo

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    NSLog(@"inside Delegate image pick");

    [popover dismissPopoverAnimated:YES];
    [picker dismissViewControllerAnimated:YES completion:NULL];
}

这样工作正常,但我遇到了imagePickerControllerDidCancel委托方法的问题。

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    NSLog(@"inside Cancel ");

    [popover dismissPopoverAnimated:YES];

    [picker dismissViewControllerAnimated:YES completion:NULL];
}
永远不会打电话给{p> imagePickerControllerDidCancel,我不知道为什么。如何在用户单击取消时关闭弹出窗口?

1 个答案:

答案 0 :(得分:0)

如果imagePickerControllerDidCancel未接到来电,则表示您需要实施UIImagePickerControllerDelegate

实施例

@interface ImageViewController : UIViewController<UIImagePickerControllerDelegate>