开发者

How to access camera of iPhone using phonegap app

I have a simple application developed for android which takes a photo, accessing the camera of device. I want the same application to be run on iPhone. For android we write permissions for accessing camera in manifest file. How do you access the camera in iPhone. Where 开发者_Go百科do we need to set up it. Can anyone please help me?

Thanks in advance


Use the Media Capture API in the latest code, or wait for 0.9.6: http://docs.phonegap.com/phonegap_media_capture_capture.md.html


For accessing the camera in iPhone, you can use following code.

// Camera

UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];

imgPicker.delegate = self;

imgPicker.allowsImageEditing = YES;

imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;

//[self presentModalViewController:imgPicker animated:YES];

[objParent presentModalViewController:imgPicker animated:YES];

[imgPicker release];

Let me know in case of any difficulty.

Below are the delegate method for camera.

Delegate Name: UIImagePickerControllerDelegate, UINavigationControllerDelegate

Methods:

#pragma mark UIImagePickerController delegate

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    // Access the uncropped image from info dictionary

    UIImage *imgCapturePhoto = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    [imgPhoto setImage:imgCapturePhoto];

    [self dismissModalViewControllerAnimated:YES];
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker

{

    [picker dismissModalViewControllerAnimated:YES];

}

Cheers

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜