拍摄图像并将其保存在iPhone上

时间:2011-11-25 11:23:55

标签: iphone objective-c xcode

我正在寻找一个教程,我可以使用我的iPhone拍照并将其保存在手机上。我用Google搜索了这个,但是无法找到任何教程或示例代码。有人可以通过指出教程或示例代码来帮助我吗?

3 个答案:

答案 0 :(得分:3)

答案 1 :(得分:2)

通过相机获取图像请参阅以下文章:

Camera Programming Topics for iOS

UIImagePickerController Class Reference

答案 2 :(得分:1)

拍摄图像的代码

UIPicker.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:UIPicker animated:YES];

成功捕获图像

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage  *)image editingInfo:(NSDictionary *)editingInfo {


    //code to save image in gallary
    UIImageWriteToSavedPhotosAlbum(receivedImage, nil,nil, nil);

     //close the picker
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];

}

捕获图像失败

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
     //close the picker
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}