Pergunta

When I add an NSImageCell to a xib it has an image property where I can see some of the NSImage standard art work. From the doc it looks like quite a few, but in the drop down, I get less. Specifically I'm looking for.

NSString *const NSImageNameStatusAvailable;
NSString *const NSImageNameStatusPartiallyAvailable;
NSString *const NSImageNameStatusUnavailable;
NSString *const NSImageNameStatusNone;

I'm able to set the image in the code, but I'd like to line everything up in the xib. Is there a reason it's not available in the drop down? I'd like to not see an empty NSImageCell in the xib either. Is there a way to find the host image's size so I can size the xib without actually NSLog'ing it's dimensions (assuming I want to use a bunch of host images).

Foi útil?

Solução

Near as I can tell, the images in the nib editor are the union of four sets:

  • Template images (for, e.g., buttons)
  • Toolbar icons
  • Icons defined by Icon Services (e.g., the Caution icon)
  • Images you've added to your project

Anything not in any of those sets isn't included. Probably worth reporting as a bug.

In the meantime, you can set it to “NSStatusAvailable” (the constant name minus the “ImageName” part) and it will work at run time.

Thus, you could cheat by extracting the various icons—whichever ones you need to use in your nib—with a separate app and then adding them to your project, but not to any of your targets. They'll still show up in the pop-up (as of 4.6.1), but won't be copied into your app bundle, so your app will use the system-provided ones.

Of course, Apple could always change the images and their sizes, so it's probably safer to get them at run time and resize/rearrange the views as needed to fit. On the other hand, unless you plan on adding support for any random image to be in that spot (e.g., something like Adium's status icon packs), I wouldn't blame you for taking the lazy way out and just sizing the view/cell to the images' current size, with a note somewhere to update it if they ever do change.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top