使用 UIImageWriteToSavedPhotosAlbum 将图像保存到相机胶卷
用户使用相机拍摄照片后,我尝试使用按钮将照片保存到相机胶卷中,但我不知道为什么我的照片没有保存在照片库中!
这是我的代码:
-(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
。
我有什么问题吗?
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 !!
Here is my code :
-(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];
}
Variable name ipc
is UIImagePickerController
and img
is UIIMageView
.
what's my problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先确保您正在调用
savePhoto
。然后你可以添加一个断言来检查图像是否不为零:First make sure you are calling
savePhoto
. Then you can add an assertion to check that the image is not nil: