我使用的是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
,我不知道为什么。如何在用户单击取消时关闭弹出窗口?
答案 0 :(得分:0)
如果imagePickerControllerDidCancel
未接到来电,则表示您需要实施UIImagePickerControllerDelegate
实施例
@interface ImageViewController : UIViewController<UIImagePickerControllerDelegate>