如题 链接直接打开是张图片
UIImage *image =[UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
NSLog(@"image:%@",image);
这样打印出来是image:(null) 为什么啊
如题 链接直接打开是张图片
UIImage *image =[UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
NSLog(@"image:%@",image);
这样打印出来是image:(null) 为什么啊
我也遇到了这个问题,不过我解决了。如果[NSData dataWithContentsOfURL:url]返回为空,那么在需要传递url时使用stringByAddingPercentEscapesUsingEncoding将字符串转成url以转换中文中的一些特殊字符.如果[NSData dataWithContentsOfURL:url]依然返回有值,那么有可能你传的url是网页的url,而不是图片的url(我就是这个错误)。
2 回答1k 阅读
1 回答1.1k 阅读✓ 已解决
1 回答2.7k 阅读
1 回答1.5k 阅读
1 回答1.4k 阅读
1.7k 阅读
1 回答1.1k 阅读
这样写是没有错的,把url在浏览器里面打开,看是不是一张完整的图片,有可能url不对