我需要设置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
进行检查?
答案 0 :(得分:2)
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
当弹出控制器解除
时,这是委托方法答案 1 :(得分:1)
将popover的委托设置为self,你也可以使用两个popover代理,即
/* 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
的委托 popover.delegate = self;