Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ildandi

macrumors newbie
Original poster
Nov 7, 2012
16
0
In my app, in XCode I show Resources folder with all images: Resources/iphone

image@2x~iphone.png
image~iphone.png

In my storyboard I've all views but in proprieties I show that images have naming like this:

"image.png"

(all images without ~iphone.png)

is this OK? or is it a problem?


Strange thing is this:

In Storyboard I show "?" when I've images because can't show linked image (wrong name, missed ~iphone e @2x~iphone)

but

When I build and run app on device I show all images OK!

Where is it the problem?

Thanks
 

Reason077

macrumors 68040
Aug 14, 2007
3,606
3,644
You should not specify the "@2x~iphone.png" part of the filename in your code or in interface builder. Just "image".

If your project works on multiple devices, you'll likely have several instances of each file depending on whether it's for iPhone, iPad, retina, or non-retina display. In some cases you should omit the "~iphone" part, if you want to use the same resource regardless of whether its an iPhone or iPad.

At runtime, iOS will select the correct file based on the device.
 

ildandi

macrumors newbie
Original poster
Nov 7, 2012
16
0
Can you help to understand how to set right structure!

You should not specify the "@2x~iphone.png" part of the filename in your code or in interface builder. Just "image".

Do you mean that I've to set

imagename.png

and not
imagename@2x~iphone.png
imagename~iphone.png



If your project works on multiple devices, you'll likely have several instances of each file depending on whether it's for iPhone, iPad, retina, or non-retina display.

App is for iPhone, I don't have selected universal device but only iPhone.
What do you mean with Several Instances of each file?
I've a single Storyboard (splitted in 2 languages)


In some cases you should omit the "~iphone" part, if you want to use the same resource regardless of whether its an iPhone or iPad.

Are you talking about StoryBoard?


At runtime, iOS will select the correct file based on the device.

Why in Storyboard I show image missed?? I don't show image but "?" symbol

Thanks
 

Reason077

macrumors 68040
Aug 14, 2007
3,606
3,644
Do you mean that I've to set

imagename.png

and not
imagename@2x~iphone.png
imagename~iphone.png

Yes, but for the image to show up in Interface Builder, you do have to have a file named the same as what you specify (if not, you'll get the "?" symbol as you mentioned). But at runtime, the OS will select the correct version automatically depending on what device it's running on.

App is for iPhone, I don't have selected universal device but only iPhone.
What do you mean with Several Instances of each file?

Say you select "imagename~iphone.png" as the image file in Interface Builder. But when you run it on a retina iPhone device, it will actually automatically switch to using "imagename@2x~iphone.png" instead, if it is available.

Say you later decided to port your app to iPad as well. Then you might have an ~iPad as well as an ~iPhone variant, if you wanted to use different resources in the iPhone vs the iPad versions.

Are you talking about StoryBoard?

The same rules apply regardless of whether you're using storyboards, regular .xibs, or [UIImage imageNamed:]
 

ildandi

macrumors newbie
Original poster
Nov 7, 2012
16
0
Great!!! now it's clear

Yes, but for the image to show up in Interface Builder, you do have to have a file named the same as what you specify (if not, you'll get the "?" symbol as you mentioned). But at runtime, the OS will select the correct version automatically depending on what device it's running on.

So I need
imagename.png (for storyboard images)
imagename@2x~iphone.png (for retina)
imagename~iphone.png (for not retina)
.. what name for iPhone5?

is it OK to save these images in:
appname/image/iPhone?



you select "imagename~iphone.png" as the image file in Interface Builder. But when you run it on a retina iPhone device, it will actually automatically switch to using "imagename@2x~iphone.png" instead, if it is available.

Do you mean in views layout created in StoryBoard?
And keeping all images in same iPhone folder?



you later decided to port your app to iPad as well. Then you might have an ~iPad as well as an ~iPhone variant, if you wanted to use different resources in the iPhone vs the iPad versions.

~iPad images will be saved in appname/image/iPhone?
Is it XCode that automatically find and search right device images in my App file system structure?


I mean that I could use iPhone or iPad folders.... or other named and XCode will search and match right images? Or is there a right folder naming and position?

Thanks
 

Reason077

macrumors 68040
Aug 14, 2007
3,606
3,644
.. what name for iPhone5?

There's no difference for iPhone 5. It uses the same resources as iPhone 4 (i.e. "~iphone@2x")

is it OK to save these images in:
appname/image/iPhone?

The folder layout in your project makes no difference. You can put the images wherever you like. When XCode builds your project, it lumps all the resources together into one folder anyway.

Is it XCode that automatically find and search right device images in my App file system structure?

Not really. It's iOS that figures out the right resources to load, at runtime.

I mean that I could use iPhone or iPad folders.... or other named and XCode will search and match right images? Or is there a right folder naming and position?

A far as folders go, you can use whatever layout/names makes sense for you. But the files themselves must be named correctly.
 

ildandi

macrumors newbie
Original poster
Nov 7, 2012
16
0
You're right could be that I a little confused about folders and resources in Xocde :-(
Can you tell me differences.... and when user folders?

Thanks
 

ildandi

macrumors newbie
Original poster
Nov 7, 2012
16
0
Can you help me understsand when use Folders and when Resources??

I think that I'm little confused about this

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.