【问题标题】:Facing issue in saving image to photo library in device for ios6将图像保存到 iOS6 设备中的照片库时面临问题
【发布时间】:2012-10-03 10:49:23
【问题描述】:

我在将 UIImage 保存到 iOS 6 设备中的照片库时遇到问题。我可以将图像保存在模拟器中但不能保存在设备中。我已经更改了设备中照片的隐私设置。但我仍然无法保存图像。 下面是我用来保存图像的代码

UIImage *snap = [sharedSingleton getCopyOfMorphedImage];

    NSData* imageData =  UIImagePNGRepresentation(snap);

    UIImage* pngImage = [UIImage imageWithData:imageData];

   UIImageWriteToSavedPhotosAlbum(pngImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);


- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    if (error != nil) {
        NSLog(@"Couldn't save image");
    } else {
        NSLog(@"Saved image");
    }
}

我用上面的代码在照片库中保存了一张黑色图像

谁能帮帮我?

【问题讨论】:

    标签: iphone uiimagepickercontroller ios6 photo-gallery photolibrary


    【解决方案1】:

    请尝试记录错误消息。它将解决您的问题

    - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
    {
        if (error != nil) {
    
            NSLog(@"%@",[error localizedDescription]);        
    
        } else {
    
            NSLog(@"Saved image");
        }
    }
    

    【讨论】:

    • 我没有收到任何错误。“保存的图像”日志打印在控制台中
    猜你喜欢
    • 2015-06-19
    • 2014-03-01
    • 1970-01-01
    • 2015-10-20
    • 2017-06-10
    • 2011-05-11
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    相关资源
    最近更新 更多