UIImageWriteToSavedPhotosAlbumcrash
發表時(shí)間:2021-1-10
發布人(rén):融晨科技
浏覽次數:54
有時(shí)使用 UIImageWriteToSavedPhotosAlbum 保存圖片到(dào)相冊會crash 出(chū)現 exc_bad_access的(de)錯誤。可以(yǐ)嘗試下先将image轉爲(wéi / wèi)png,再存儲。
代碼如下:
UIImage* image = myImage;// myImage爲(wéi / wèi)自己的(de)圖片 NSData* imageData = UIImagePNGRepresentation(myImage); UIImage* newImage = [UIImage imageWithData:imageData]; UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);