开发者

Select image iphone simulator using phonegap camera api

I'm new to Xcode and iPhone apps. I want to select an image from iPhone (camera or library) and send to php via ajax.

I'm using the phonegap framework, Xcode iPhone SDK version 3.1.x. On clicking button it calls function with parameter 0 or 1, but it does not initialize camera or display the library.

I used the code in this link

it shows this error in debug console:

2010-03-25 23:36:02.337 PhoneGap[7433:207] Camera.getPicture: Camera not available.

simulator dsnt have camera, but photos(from library) also not wokring!

what might be the error? I think开发者_开发技巧 when using navigator.camera.getPicture first check for camera and if not break and shows error ~?


For using photo library in iphone simulator. You have to conforms to the delegate UINavigationControllerDelegate, UIImagePickerControllerDelegate and alloc pickerview and set delegate on it and then check

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


I don't know how are you using that framework. But UIImagePickerController is the class I use to choose photos from the iPhone library or the device's camera. And all you need to do is set it to display the library:

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

or

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

You should check it out. Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜