• 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
Re: specifying images for image views in nibs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: specifying images for image views in nibs


  • Subject: Re: specifying images for image views in nibs
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 28 Nov 2012 02:13:29 -0600

On Nov 27, 2012, at 1:16 PM, Keary Suska wrote:

> On Nov 27, 2012, at 7:26 AM, Steve Mills wrote:
>
>> How do I specify that an image view in a nib should use an image that's in a subfolder of a subfolder of the Resources directory in the bundle? Below is the hierarchy of the built app bundle. mixer.xib wants to use background.png in one of its image views.
>>
>> Resources/
>> 	English.lproj/
>> 		mixer.xib
>> 	images/
>> 		mixer/
>> 			background.png
>>
>> Additionally, the source code hierarchy is different than how it appears in the built app bundle.
>>
>> rsrc/
>> 	English.lproj/
>> 		mixer.xib
>> macrsrc/
>> 	images/
>> 		mixer/
>> 			background.png
>>
>> If I simply choose "background" from the list of "known" images in the Interface Builder inspection panel, I see the image in Interface Builder. But when I build and run the app, the image does not appear. I've tried typing in a specific partial path "images/mixer/background" and "images/mixer/background.png", but neither of those worked. What are the rules? I can find no documentation about this. When should the extension be given? So many questions - so little documentation.
>
> IMHO, you will find more happiness with Xcode when your "build" and "built" directory structures are the same. If not you will have the exact problems you are experiencing. I expect that Interface Builder is hard-coding paths as this is far more efficient than searching for every resource at runtime.

I very much doubt that Interface Builder is encoding any path information about the image in the NIB.  Interface Builder is offering any images known to the project, but what's stored in the NIB is just the image name (as it appears in IB).  At NIB-loading time, it's just using +[NSImage imageNamed:].

Steve, the documentation for that method is what you should refer to to find out what names and image locations can work.  (Although it's not as clear as it might be.  It seems to use -[NSBundle pathForResource:ofType:] or -[NSBundle URLForResource:withExtension:], both of which are documented to not search subdirectories.)

In any case, putting images into a (non-localization) subfolder of Resources makes them unavailable to +[NSImage imageNamed:].  That, in turn, means you can't use the image name when configuring an image view in IB.

Regards,
Ken


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >specifying images for image views in nibs (From: Steve Mills <email@hidden>)
 >Re: specifying images for image views in nibs (From: Keary Suska <email@hidden>)

  • Prev by Date: Linking to framework
  • Next by Date: Re: including .h files in a project with two static library targets
  • Previous by thread: Re: specifying images for image views in nibs
  • Next by thread: warning: object file compiled with -mlong-branch
  • Index(es):
    • Date
    • Thread