UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?

UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?,第1张

概述我一直在物理iOS设备上运行我的应用程序一段时间没有任何问题.但是现在UI ImagePickerController视图不会出现在模拟器上.我已经使用方法 here将照片保存到模拟器中,并确认它们确实存在于图像库中的模拟器上. Xcode中没有d出错误.我尝试过使用不同的源类型,但无济于事.知道我可能做错了什么吗?非常感谢! 码 UIImagePickerControllerSourceType 我一直在物理iOS设备上运行我的应用程序一段时间没有任何问题.但是现在UI ImagePickerController视图不会出现在模拟器上.我已经使用方法 here将照片保存到模拟器中,并确认它们确实存在于图像库中的模拟器上. Xcode中没有d出错误.我尝试过使用不同的源类型,但无济于事.知道我可能做错了什么吗?非常感谢!

UIImagePickerControllerSourceType sourceType;    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotolibrary])            {                sourceType = UIImagePickerControllerSourceTypePhotolibrary;            }            else            {                sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;            }            //display photo library.            [self startimagePickerControllerFromVIEwController: self                                            usingDelegate: self                                           withSourceType: sourceType];...- (BOol)startimagePickerControllerFromVIEwController:(UIVIEwController*) controller                                  usingDelegate:(ID <UIImagePickerControllerDelegate,UINavigationControllerDelegate>) delegate                                 withSourceType:(UIImagePickerControllerSourceType) sourceType{    //Insure camera,controller,and delegate exist.    if (([UIImagePickerController isSourceTypeAvailable:          UIImagePickerControllerSourceTypeCamera] == NO)        || (delegate == nil)        || (controller == nil))        return NO;    //Create the ImagePicker.    UIImagePickerController *imagePickerUI = [[UIImagePickerController alloc] init];    imagePickerUI.sourceType = sourceType;    //Only allow still images.    imagePickerUI.mediaTypes = [[NSArray alloc] initWithObjects: (Nsstring *) kUTTypeImage,nil];    //Turn off editing.    imagePickerUI.allowsEditing = NO;    //Set the delegate.    imagePickerUI.delegate = delegate;    //Present the picker vIEw.    [controller presentVIEwController:imagePickerUI animated:YES completion:nil];    return YES;}
解决方法
if (([UIImagePickerController isSourceTypeAvailable:      UIImagePickerControllerSourceTypeCamera] == NO)

上述条件确保模拟器无法运行它,因为模拟器没有摄像头.

总结

以上是内存溢出为你收集整理的UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?全部内容,希望文章能够帮你解决UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存