I'm developing an iOS application for a news website, the application gets its JSON data from a url, the data is an HTML and sometimes has images embedded in them like this:
<div class="row ">some text here then <div class="col-xs-12 ">
<div class="col-sm-5 col-xs-12 pull-right">
<img src="image_url" /></div></div>
By far i know how to get only text (remove all html tags) but i don't know how to display the images that are embedded in that string.
Does anyone know how to do that ?
Note i researched a lot and didn't find a solution for this.
Thanks in advance.
You could use the UIImageView+AFNetworking category. There is a method - (void)setImageWithURL:(NSURL *)url
that will allow you set the image property on UIImageView with a url and asynchronous network call.
Try this code...
NSURL *url = [NSURL URLWithString:@"http://www.fnordware.com/superpng/pnggrad16rgb.png"];//This is Example url you can write your URL.
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
[self.imageview1 setImage:image];
Beside try
self.imageview1 = [UIImage dataWithContentsOfURL@"http://www.fnordware.com/superpng/pnggrad16rgb.png"];