Created
April 9, 2010 13:47
-
-
Save ikarius/361171 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** Display image in UIWebView using loadHTMLString | |
*/ | |
- (void) showImageWithLoadHTMLString { | |
// Create URL string for image file location | |
NSString *imageName = [[NSBundle mainBundle] pathForResource:@"test_image" ofType:@"png"]; | |
NSURL *imageURL = [NSURL fileURLWithPath: imageName]; | |
// Create HTML string from image URL | |
// Width-value is arbitrary (and found experimentally): 900 works fine for me | |
NSString *htmlString = @"<html><body><img src='%@' width='900'></body></html>"; | |
NSString *imageHTML = [[NSString alloc] initWithFormat:htmlString, imageURL]; | |
// Load image in UIWebView | |
imageWebView.scalesPageToFit = YES; | |
[imageWebView loadHTMLString:imageHTML baseURL:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment