我点击按钮时从相册中获取保存的图像。在显示相册后我没有在iPad上取消按钮取消相册。从相册中选择任何已保存的图像后,关闭并将拾取图像添加到UIImageView。但是如果没有从图库中选择图像,我就无法关闭相册。在iphone中,它正在使用取消。
-(void)picker:(id)sender{
if ([self->popoverController isPopoverVisible]) {
[self->popoverController dismissPopoverAnimated:YES];
} else {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
imagePicker=[[UIImagePickerController alloc]init];
imagePicker.delegate = self;
imagePicker.allowsEditing =NO;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self->popoverController = [[UIPopoverController alloc]
initWithContentViewController:imagePicker];
self->popoverController.delegate = self;
CGRect popoverRect = [self.view convertRect:[self.view frame]
fromView:[self.view superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 100) ;
popoverRect.origin.x = popoverRect.origin.x+10;
[self->popoverController
presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
//release picker
// [picker dismissModalViewControllerAnimated:YES];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[picker dismissViewControllerAnimated:YES completion:nil];
}else{
[picker dismissViewControllerAnimated:YES completion:nil];
if (popoverController != nil) {
[popoverController dismissPopoverAnimated:YES];
popoverController=nil;
}
}
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
if (popoverController != nil) {
[popoverController dismissPopoverAnimated:YES];
popoverController=nil;
}
[picker dismissViewControllerAnimated:YES completion:nil];
}
答案 0 :(得分:0)
您正在popoverController中呈现imagePickerController,因此它不会有“手动取消”按钮,因为您可以点击弹出窗口外的任何位置来关闭它。
答案 1 :(得分:0)
我以前遇到过这个问题。请在下面的问题中查看接受的答案。它对我有用。
UIImagePickerController inside UIPopoverController doesn't show Cancel button on iOS7