UIImageWriteToSavedPhotosAlbum crash

来源:互联网 发布:网络诈骗论文2000字 编辑:程序博客网 时间:2024/05/17 04:09

有时使用 UIImageWriteToSavedPhotosAlbum 保存图片到相册会crash 出现 exc_bad_access的错误。可以尝试下先将image转为png,再存储。

代码如下:

    UIImage* image = myImage;// myImage为自己的图片    NSData* imageData =  UIImagePNGRepresentation(myImage);    UIImage* newImage = [UIImage imageWithData:imageData];    UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);

也有可能是图片过大导致崩溃

使用如下代码:

    NSData* imageData =  UIImageJPEGRepresentation(myImage, 0.1);    UIImage* newImage = [UIImage imageWithData:imageData];    UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);



0 0
原创粉丝点击