2012-07-21 39 views
1

我是iPhone開發的新手。我需要製作一個應用程序,用戶可以在該應用程序中拍攝照片,然後將其保存在iPhone上,還必須使用SQLite數據庫來存儲圖像並稍後顯示它。iOS幫助:如何使用相機拍照並將其保存在iPhone上?

任何人都可以幫助我的示例代碼和程序的解釋?

編輯:我做了一個使用的UIImageView進行拍照按鈕,但我不知道它的作品,因爲我沒有一個iPhone:

if ([UIImagePickerController isSourceTypeAvailable: 
    UIImagePickerControllerSourceTypeCamera]) 
{ 
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.delegate = self; 
    imagePicker.sourceType = 
    UIImagePickerControllerSourceTypeCamera; 
    imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil]; 
    imagePicker.allowsEditing = NO; 
    [self presentModalViewController:imagePicker animated:YES]; 
    imagePicker = nil; 
    newMedia = YES; 
} 

上面的代碼使用了前置攝像頭

+1

Shahnawaz - 有任何的教程在那裏對這個話題,與蘋果的WWDC視頻,甚至在YouTube視頻。你有沒有努力去搜索這些資源? – 2012-07-21 07:12:43

+1

我一直在尋找關於如何存儲文件路徑以及如何保存圖片的建議。我嘗試了一些我不知道它需要展示的東西,但是我現在編輯帖子並展示它。 – Shahnawaz 2012-07-22 04:55:51

回答

11

你可以使用UIImagePickerController類拍照.. 可用於捕獲圖像下面的方法,並將其存儲..

UIImagePickerController * picker = [[UIImagePickerController alloc] init]; 
picker.delegate = self; 
picker.sourceType = UIImagePickerControllerSourceTypeCamera; 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    //put code for store image 
}     
+0

@Janak Nirmal我希望用戶擁有最新的顯示圖片。是否可以僅拍攝新照片並防止選擇現有選項? – harishannam 2014-09-06 06:23:32

4

可以使用EXA在蘋果的開發者庫

可用mples看到這些例子

,還有更多的參考材料可用了。

編碼快樂:)

相關問題