[英]UIImagePickercontroller cancel button not display in iPad
單擊按鈕時,我正在從相冊中保存圖像。 取消相冊后,我在iPad中沒有“取消”按鈕以取消相冊。 選擇任何人從相冊中保存圖像后,它將關閉並將拾取圖像添加到UIImageView。 但是如果沒有從圖庫中選擇圖片,我將無法關閉相冊。 在iPhone中,它正在使用cancel。
-(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];
}
您將在popoverController中顯示imagePickerController,因此它將沒有“手動取消”按鈕,因為您可以點擊彈出框之外的任何位置以將其關閉。
我以前遇到過這個問題。 請在下面的問題中檢查接受的答案。 它為我工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.