• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
WebView Loading Images from Local Filesystem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: WebView Loading Images from Local Filesystem
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: determining HTML text encoding
  • Next by Date: Re: Tabbing between cells in a complex control
  • Previous by thread: Re: OpenAL and file size
  • Next by thread: Re: WebView Loading Images from Local Filesystem
  • Index(es):
    • Date
    • Thread