Load image and text in one UIWebView
HI guys. I need to load image and text in UIWebView, I loaded image like that
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageUrl]; [myWebView loadData:imageDa开发者_StackOverflowta MIMEType:@"application/jpg" textEncodingName:nil baseURL:nil];
and text like that
[myWebView loadHTMLString:self.text baseURL:nil];
But when I put it together I see just image, because it is the last in code. How can I load both (image and text) to one UIWebView? Thank you
You can create html-page dynamically and load it into UIWebView:
NSString *imageUrlString = @"http://www.gstatic.com/translate/intl/ru/logo.png";
NSString *yourText = @"Some text here";
NSString *htmlString = [NSString stringWithFormat:@"<img src='%@'/><br><b>%@</b>", imageUrlString, yourText];
[myWebView loadHTMLString:htmlString baseURL:nil];
精彩评论