1

please hepl if some body had same problem... I have sqlite db, with images in NSData. I need to insert image in uiwebview but... the image do not show....

NSString *html = [NSString stringWithFormat:
                   @"<html> <head>"
                   @"<style> body { font-family:Verdana;font-size:13px;}</style>"
                   @"</head>"
                   @"<img src=\"%@\" />"
                   @"<br/>%@"
                   @"</body> </html>", datePicture,strDescription]] ;

And then i insert it in UIWebview:

[descripWebView loadHTMLString:html baseURL:nil];
1
  • images in NSDate??? Did you mean NSData? Commented Mar 20, 2012 at 9:22

1 Answer 1

3

If your datePicture is of type UIImage, you could encode the image in base64 and embed that directly to your HTML.

NSString *html = [NSString stringWithFormat:
                   @"<html> <head>"
                   @"<style> body { font-family:Verdana;font-size:13px;}</style>"
                   @"</head>"
                   @"<img src=\"data:Image/jpeg;base64,%@\" />"
                   @"<br/>%@"
                   @"</body> </html>", 
       [QSStrings encodeBase64WithData:UIImageJPEGRepresentation((datePicture, 1.0)],
       strDescription];

Note that I'm using QSStrings to do the encoding, which can be found in QSUtilities on github

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.