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 > NSStatusItem icon not showing

NSStatusItem icon not showing
Thread Tools
Fresh-Faced Recruit
Join Date: May 2002
Location: Ft Lauderdale
Status: Offline
Reply With Quote
Jun 12, 2002, 01:56 AM
 
Hi, I have an NSStatusItem app. The item works, I can use setTitle and that shows up, but my icon wont show up.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
NSStatusItem *statusItem = [[statusBar statusItemWithLength:NSSquareStatusItemLength] retain];
NSImage *myIcon = [[NSImage alloc] initWithContentsOfFile:@&quot;myIcon.tiff& quot;];

[statusItem setImage:myIcon];</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I added the image to the resources and all that. I also tried initByReferencingFile to init the image, no difference. Can anyone think of anything?
TIA,
Mark
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jun 12, 2002, 02:25 AM
 
have you tried [NSImage imageNamed:@"myIcon.tiff"]?
     
Fresh-Faced Recruit
Join Date: May 2002
Location: Ft Lauderdale
Status: Offline
Reply With Quote
Jun 12, 2002, 11:15 AM
 
I just tried that, same thing. All I'm getting is the blank space where it should be. I'll keep working on it, any other ideas?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 12, 2002, 12:41 PM
 
Try:
NSImage *myIcon = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myIcon" ofType:@"tiff"]];
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jun 12, 2002, 12:42 PM
 
just an idea... where do you declare the nsstatusitem? in the method that sets it up? have you tried moving the declaration to your header file?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 13, 2002, 01:57 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by seb2:
<strong>just an idea... where do you declare the nsstatusitem? in the method that sets it up? have you tried moving the declaration to your header file?</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">That wouldn't make any difference. The statusitem will still exist even if you don't have a pointer to it.
     
Fresh-Faced Recruit
Join Date: May 2002
Location: Ft Lauderdale
Status: Offline
Reply With Quote
Jun 13, 2002, 03:13 PM
 
The problem was I put the image file in PB resources(like you would for an app icon), but it needed to be in IB's images panel( <img border="0" alt="[Hmmm]" title="" src="graemlins/hmmm.gif" /> ). Thanks for the help.
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jun 13, 2002, 03:54 PM
 
agnus, you're right, of course. stupid me.

vasudevelopa, you mean you're storing the images *inside* the nib? that's possible, but that method of storing images is deprecated.
     
Fresh-Faced Recruit
Join Date: May 2002
Location: Ft Lauderdale
Status: Offline
Reply With Quote
Jun 13, 2002, 07:24 PM
 
Really? I don't understand why the image wouldn't draw until it was added to the NIB. All of the code posted should potentially work...
     
   
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 01:21 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