UIImagePickerController在iPhone和iPad上的区别

UIImagePickerController在iPhone和iPad上的区别,第1张

概述在iPhone中获取照片库的常用方法如下:  UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];   if ([UIImagePickerController isSourceTypeAvailable:            UIImagePickerControllerSourceType 在iPhone中获取照片库的常用方法如下:  UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];   if ([UIImagePickerController isSourceTypeAvailable:            UIImagePickerControllerSourceTypePhotolibrary]) {       imagePicker.sourceType = UIImagePickerControllerSourceTypePhotolibrary;       imagePicker.delegate = self;       [imagePicker setAllowsEditing:NO];       [self presentModalVIEwController:imagePicker animated:YES];       [imagePicker release];   } else {       UIAlertVIEw *alert = [[UIAlertVIEw alloc]initWithTitle:nil message:@"Error accessing photo library!" delegate:nil cancelbuttonTitle:@"Close" otherbuttonTitles:nil];       [alert show];       [alert release];   }  

 

这在iPhone下 *** 作是没有问题的,但在iPad下就会有问题了,运行时会报出下面的错误:

 

Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: 'On iPad,UIImagePickerController must be presented via UIPopoverController'

 

所以,我们必须通过UIPopoverController来实现才行。具体的实现如下:

 

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentVIEwController:imagePicker];       self.popoverController = popover;       [popoverController presentPopoverFromrect:CGRectMake(0300,0)">300) inVIEw:self.vIEw permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];       [popover release];   }  
转自:http://2015.iteye.com/blog/1340797 总结

以上是内存溢出为你收集整理的UIImagePickerController在iPhone和iPad上的区别全部内容,希望文章能够帮你解决UIImagePickerController在iPhone和iPad上的区别所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1090225.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存