我正在尝试让我的应用程序打开相机应用程序以保存照片。
我正在从我的应用程序中启动相机应用程序以使用以下代码拍照:
-(IBAction)TakePhotoid)sender {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:NULL];
[picker release];
//save image??:
//UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
}
-(void) imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(void)imagePickerControllerDidCancelUIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:NULL];
}
我的问题是,一旦按下按钮,相机就会出来并让我拍照。拍完照片后,图像就会显示出来,我可以选择“重拍”或“使用”。我的问题是,如果我单击“使用”,图像不会保存到相机胶卷中。是否有可能保存图像并最终将“使用”按钮更改为“保存”?
感谢您的帮助!
Best Answer-推荐答案 strong>
没有保存照片,因为您实际上从未将用于保存图像的代码添加到 didFinishPickingMediaWithInfo: 委托(delegate)方法。您所要做的就是将您在 TakePhoto: 中注释掉的行添加到此函数中,您就可以将照片保存到相机胶卷中。例如:
-(void) imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, NULL);
[self dismissViewControllerAnimated:YES completion:NULL];
}
关于ios - 从应用程序保存图片,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/19409428/
|