max图像io错误_iOS对图像损坏错误:<Error>:ImageIO的处理方法

图片能正常显示么?

如果不能正常显示的话,你可以自己先做一个验证操作,如果自己验证过了再赋值给imageView,这种错误也不该无视吧?毕竟图片确实有问题。

如果你实在想让它不显示,我觉得有三条个办法:

Method Swizzling 替换掉打日志的那个方法

日志重定向

检测是不是只有在定义 DEBUG 宏的时候才输出,如果是的话就好办了,在设置的时候取消宏,然后再给加上

so上找到的检测 PNG 的方法:

- (BOOL)dataIsValidPNG:(NSData *)data

{

if (!data || data.length < 12)

{

return NO;

}

NSInteger totalBytes = data.length;

const char *bytes = (const char *)[data bytes];

return (bytes[0] == (char)0x89 && // PNG

bytes[1] == (char)0x50 &&

bytes[2] == (char)0x4e &&

bytes[3] == (char)0x47 &&

bytes[4] == (char)0x0d &&

bytes[5] == (char)0x0a &&

bytes[6] == (char)0x1a &&

bytes[7] == (char)0x0a &&

bytes[totalBytes - 12] == (char)0x00 && // IEND

bytes[totalBytes - 11] == (char)0x00 &&

bytes[totalBytes - 10] == (char)0x00 &&

bytes[totalBytes - 9] == (char)0x00 &&

bytes[totalBytes - 8] == (char)0x49 &&

bytes[totalBytes - 7] == (char)0x45 &&

bytes[totalBytes - 6] == (char)0x4e &&

bytes[totalBytes - 5] == (char)0x44 &&

bytes[totalBytes - 4] == (char)0xae &&

bytes[totalBytes - 3] == (char)0x42 &&

bytes[totalBytes - 2] == (char)0x60 &&

bytes[totalBytes - 1] == (char)0x82);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值