2010-03-26 95 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]; 
     }