本文介绍了使用 UIImageWriteToSavedPhotosAlbum 将图像保存到相机胶卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在用户使用相机拍摄照片后,我正在尝试使用按钮将照片保存到相机胶卷,但我不知道为什么我的照片没有保存在照片库中!
I am trying to save a photo with a button to camera roll after user capture a picture with Camera , but I don't know why my picture doesn't save at photo library !!
这是我的代码:
-(IBAction)savePhoto{
UIImageWriteToSavedPhotosAlbum(img.image,nil, nil, nil);
}
-(IBAction)takePic {
ipc = [[UIImagePickerController alloc]init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:ipc animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
img.image = [[info objectForKey:UIImagePickerControllerOriginalImage]retain];
[[picker parentViewController]dismissModalViewControllerAnimated:YES];
[picker release];
}
变量名ipc
是UIImagePickerController
,img
是UIIMageView
.
我的问题是什么?
推荐答案
首先确定你调用的是savePhoto
.然后你可以添加一个断言来检查图像不为零:
First make sure you are calling savePhoto
. Then you can add an assertion to check that the image is not nil:
- (IBAction) savePhoto {
NSParameterAssert(img.image);
UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil);
}
这篇关于使用 UIImageWriteToSavedPhotosAlbum 将图像保存到相机胶卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!