-1

我需要设置UIPopOverController从库中选择照片。

所以我写了以下代码。

self.imagePickerController = [[UIImagePickerController alloc] init];
    self.imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
    self.imagePickerController.sourceType = sourceType;
    [self.imagePickerController setDelegate:self];

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:self.imagePickerController];

    [popover presentPopoverFromRect:self.btnArchive.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
    imagePickerPopover = popover;

它出现了,我从照片库中选择了一张照片,在我从库中选择后,我使用以下代码关闭了 PopOver。

[self.imagePickerPopover dismissPopoverAnimated:NO];

我需要显示从照片库中选择的图像,所以我在 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info方法中编写了以下代码。

UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];

[self dismissViewControllerAnimated:YES completion:^ {

// Codes Here after dismiss PopOverView and chosen photo from library

}];

但它不起作用。我如何检查它UIPopOverController

4

2 回答 2

2
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController   
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController

这是弹出框控制器关闭时的委托方法

于 2013-09-08T14:31:40.680 回答
1

将弹出框的代表设置为 self ,您也可以使用两个弹出框代表,即

/* Called on the delegate when the popover controller will dismiss the popover. Return NO to prevent the dismissal of the view.
 */
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController;
/* Called on the delegate when the user has taken action to dismiss the popover. This is not called when -dismissPopoverAnimated: is called directly.
 */
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController;

然后将您的 MainViewController 实例设置为弹出框的委托

popover.delegate = self;

于 2013-09-08T14:36:33.913 回答