使用phonegap相机api选择图像iPhone模拟器

问题描述 投票:0回答:2

我是 Xcode 和 iPhone 应用程序的新手。我想从 iPhone(相机或库)中选择图像并通过 ajax 发送到 PHP。

我使用的是phonegap框架,Xcode iPhone SDK版本3.1.x。单击按钮时,它会调用参数为 0 或 1 的函数,但不会初始化相机或显示库。

我使用了此链接中的代码。

它在调试控制台中显示此错误:

2010-03-25 23:36:02.337 PhoneGap[7433:207] Camera.getPicture:相机不可用。

模拟器没有相机,但照片(来自图库)也不起作用!

可能出现什么错误? 我认为使用

navigator.camera.getPicture
时首先检查相机,如果没有损坏并显示错误〜?

javascript ios cordova camera
2个回答
1
投票

用于在 iPhone 模拟器中使用照片库。您必须符合委托 UINavigationControllerDelegate、UIImagePickerControllerDelegate 并分配 pickerview 并在其上设置委托,然后检查

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            [self presentModalViewController:imagePickerView animated:YES];
        }

-1
投票

我不知道你如何使用该框架。但 UIImagePickerController 是我用来从 iPhone 库或设备相机中选择照片的类。您需要做的就是将其设置为显示库:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
//set your delegate and other properties...
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

你应该检查一下。 干杯

© www.soinside.com 2019 - 2024. All rights reserved.