Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Using an image in my bundle in a WebView...

Using an image in my bundle in a WebView...
Thread Tools
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
May 28, 2004, 01:36 PM
 
Hey guys,

I'm having a problem with getting a image from my .app to display in my WebView.

Here is what I use trying to get it to display:

Code:
NSString *image = [[NSBundle mainBundle] pathForResource:@"CodeHelpBrowser" ofType:@"png"]; NSLog(@"%@",image); NSString *html = [NSString stringWithFormat:@"<img src=\"%@\" alt=\"Code Help Browser\" width=\"269\" height=\"150\" />", image]; [[helpWebView mainFrame] loadHTMLString:html baseURL:[NSURL URLWithString:@"about:blank"]];
The NSLog outputs the correct path:

2004-05-28 19:36:27.575 Tag[1982] /Volumes/Home/Users/olivercameron/Projects/Builds/Tag.app/Contents/Resources/CodeHelpBrowser.png

But, the image just displays as an X in my WebView. Any ideas appreciated,
Oliver
     
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
May 28, 2004, 01:38 PM
 
Just a guess, but have you tried appending file:// to the front of the image path?
     
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
May 28, 2004, 02:08 PM
 
Originally posted by itai195:
Just a guess, but have you tried appending file:// to the front of the image path?
That worked, thanks

Oliver
     
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
May 28, 2004, 02:46 PM
 
No prob. I'm doing my first experimentation with WebViews these days. Being a little annoyed that I can't seem to easily get a border drawn around it...
     
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
May 28, 2004, 02:55 PM
 
Originally posted by itai195:
No prob. I'm doing my first experimentation with WebViews these days. Being a little annoyed that I can't seem to easily get a border drawn around it...
I had the same problem with a border, at first I subclassed it and drew the border myself. But then it didn't work too good, I gave up and used a NSBox subclass with custom color. If you want how to change its color, I'll post the code.

Thanks,
Oliver
     
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
May 28, 2004, 09:00 PM
 
Thanks Oliver, I got it working fine in an NSBox.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:33 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2