2010-03-26 90 views
0

我是新来的Xcode和iPhone应用程序。我想从iPhone(相机或库)中选择一个图像并通过ajax发送给php。选择图像iphone模拟器使用phonegap相机api

我正在使用phonegap框架,Xcode iPhone SDK版本3.1.x.点击按钮时,它会调用参数0或1的函数,但不会初始化摄像头或显示库。

我使用的代码在this link

它表明这个错误在调试控制台:

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

模拟器dsnt有摄像头,但照片(从库)还没有工作呢!

什么可能是错误? 我觉得当使用navigator.camera.getPicture首先检查相机,如果不休息并显示错误〜?

回答

-1

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

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

picker.sourceType = UIImagePickerControllerSourceTypeCamera; 

你应该看看。 干杯

1

在iphone模拟器中使用照片库。你必须符合委托UINavigationControllerDelegate,UIImagePickerControllerDelegate并分配pickerview并设置它的委托,然后检查

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