使用 UIImageWriteToSavedPhotosAlbum 将图像保存到相机胶卷

发布于 2024-08-27 03:55:15 字数 836 浏览 1 评论 0原文

用户使用相机拍摄照片后,我尝试使用按钮将照片保存到相机胶卷中,但我不知道为什么我的照片没有保存在照片库中!

这是我的代码:

-(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];   
}

变量名ipcUIImagePickerControllerimgUIIMageView

我有什么问题吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花心好男孩 2024-09-03 03:55:15

首先确保您正在调用savePhoto。然后你可以添加一个断言来检查图像是否不为零:

- (IBAction) savePhoto {
    NSParameterAssert(img.image);
    UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil);
}

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文