I am receiving an image, title and description from a json file and i need to display this on a view. I am using webview because the description attribute has links and is in html format so webview is easiest. However now i need to add the image and title above the description. I know how i can add an image seperately but i dont know how i can add all these three components in the webview. Any help? Thank you
NSString * myHTMLImage = @"<img src='Hop.png'>";
NSString *imagePath = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:imagePath];
[self.webView loadHTMLString:myHTMLImage baseURL:baseURL];
The above code embeds an image to the entire webview.
[self.webView loadHTMLString:bodyOfText baseURL:nil];
I need to be able to do the above loading of bodyOfText as wel. and a title too. which is a string. How do i do it.
You just build up your HTML string. You could do something like:
I usually build my references to images right in the
srctag, that way I can easily refer to both images in my bundle as well as images in myDocumentsfolder in the same HTML string.