我有一个为Android开发的简单应用程序,它拍摄一张照片,访问设备的相机。 我想要在iPhone上运行相同的应用程序。对于android,我们编写访问清单文件中相机的权限。你如何在iPhone中使用相机?我们需要在哪里设置它。谁能帮帮我吗?如何使用phonegap应用程序访问iPhone的相机
在此先感谢
我有一个为Android开发的简单应用程序,它拍摄一张照片,访问设备的相机。 我想要在iPhone上运行相同的应用程序。对于android,我们编写访问清单文件中相机的权限。你如何在iPhone中使用相机?我们需要在哪里设置它。谁能帮帮我吗?如何使用phonegap应用程序访问iPhone的相机
在此先感谢
对于iPhone访问摄像机,你可以使用下面的代码。
// 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];
如果遇到任何困难,请通知我。
下面是相机的代表方法。
代表名称:UIImagePickerControllerDelegate,UINavigationControllerDelegate
方法:
#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];
}
干杯
使用最新的代码媒体捕获API,或者等待0.9.6: http://docs.phonegap.com/phonegap_media_capture_capture.md.html
对不起,我没有提到我使用phonegap。如何使用phonegap应用程序使相机使用.. – Hima 2011-06-16 10:57:00
谢谢。但我使用phonegap.I没有在objective-c中开发单个应用程序,我应该使用此代码 – Hima 2011-06-16 11:00:45
嗨,您可以在buuton click事件中使用此代码。而其余的委托方法是。让我知道任何疑问。 – 2011-06-16 12:16:53