简体   繁体   English

如何在Yelp API中显示“ image_url”中的图像?

[英]How do you display image from “image_url” in Yelp API?

I now understand how to parse and display JSON data, but one thing eludes me: when I call "image_url" and receive the actual URL, how can I instead display the image that it refers to? 现在,我了解了如何解析和显示JSON数据,但有一件事情使我难以理解:当我调用“ image_url”并接收实际的URL时,如何显示它所引用的图像? ...and yes, I am a novice :) ...是的,我是新手:)

Thanks! 谢谢!

You can do that like this: 您可以这样做:

UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:theUrl]]];

where theUrl is the url in string format. 其中theUrl是字符串格式的URL。 Then simply assign the image to your image view: imageView.image = image - presuming you have set up a UIImageView either in your code, as an IBOutlet or as a tagged object in a view. 然后,只需将图像分配给图像视图即可: imageView.image = image image-假定您已在代码中将UIImageView设置为IBOutlet或视图中的标记对象。

NOTE: You may want to have a look at Lazy Table Images to load the image asynchronously. 注意:您可能需要查看惰性表映像以异步加载映像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM