Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally fixed the issue with the below code. It might be inefficient but this was all I could get for the moment.</p> <pre><code>__block NSData *imageData = [NSData data]; SDImageCache *imageCache = [SDImageCache sharedImageCache]; [imageCache queryDiskCacheForKey:_articles.articleImageURL done:^(UIImage *image, SDImageCacheType cacheType) { imageData = UIImagePNGRepresentation(image); NSMutableString *summaryString = [[NSMutableString alloc]initWithData:[_articles articleSummary] encoding:NSUTF8StringEncoding]; NSString *headerString = [NSString stringWithFormat:@"&lt;html&gt;&lt;head&gt;&lt;style type=\"text/css\"&gt; div{text-align:justify;text-justify:inter-word;margin:auto}img {max-width:100%%;width:auto;height:auto;}body{font-family: Verdana;font-size: 12pt;max-width: 100%%; width:auto; height:auto;}&lt;body bgcolor=\"#F5F5DC\"&gt;&lt;/style&gt;&lt;body&gt;"]; if (image) { NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"&lt;img[^&gt;]*&gt;" options:NSRegularExpressionCaseInsensitive error:nil]; [regex replaceMatchesInString:summaryString options:0 range:NSMakeRange(0, summaryString.length) withTemplate:@""]; NSString *imageSource = [NSString stringWithFormat:@"data:image/png;base64,%@",[imageData base64Encoding]]; NSString *imageSOruceWithTag = [NSString stringWithFormat:@"&lt;img src='%@' /&gt;", imageSource]; NSMutableString *myDescriptionHTML = [NSMutableString stringWithFormat:@"%@%@%@&lt;/body&gt;&lt;/html&gt;",headerString, imageSOruceWithTag,summaryString]; [_webView loadHTMLString:myDescriptionHTML baseURL:[NSURL URLWithString:[_articles originUrl]]]; } else { NSString *descriptionHTML = [NSString stringWithFormat:@"%@%@&lt;/body&gt;&lt;/html&gt;",headerString,summaryString]; [_webView loadHTMLString:descriptionHTML baseURL:[NSURL URLWithString:[_articles originUrl]]]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload