WebView Loading Images from Local Filesystem
WebView Loading Images from Local Filesystem
- Subject: WebView Loading Images from Local Filesystem
- From: Jon Buys <email@hidden>
- Date: Sun, 31 Jan 2010 15:24:55 -0600
Hello,
I have a WebView where I am loading html like this:
NSString *baseContextFile = [[NSBundle mainBundle] pathForResource:@"base"
ofType:@"html"];
baseHTMLString = [[NSString stringWithContentsOfFile:baseContextFile
encoding:NSUTF8StringEncoding
error:NULL] retain];
[[webView mainFrame] loadHTMLString: baseHTMLString baseURL:[NSURL URLWithString:@""]];
I'd like to be able to load images using an <img> tag in my HTML from my ~/Library/Application Support/ directory. I've been trying to use baseURL, but I get strange results when I create a file URL that points to my Application Support directory. The Apple docs seem a little vague on the subject, saying only that the baseURL is "A file that is used to resolve relative URLs within the document." If that's true, then I should be able to point the baseURL wherever I want.
- (void)webView:(WebView *)someWebView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener {
[listener ignore];
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
}
I'm sure that once again I'm missing something basic, but any pointers in the right direction are appreciated.
Thanks,
-- Jon
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden