NSURL *imageUrl = [NSURL URLWithString:@"http://image.ohozaa.com/i/3ca/inIHge.jpg"];
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
UIImage *image = [UIImage imageWithData:imageData];
image
return nil
但UIImage
可以正常显示另一个url
可以在此URL设置UIImage
吗?
图片加载时间超过1分钟。将映像放在更快的服务器上,或者使用更可靠的方法下载数据。NSData dataWithContentsOfURL
不处理错误,也不允许您配置超时。一般不建议使用
相反,要么用NSURLConnection自己滚,要么尝试AFNetworking(在github上)。