Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 7, 2012, 07:12 AM   #1
ildandi
macrumors newbie
 
Join Date: Nov 2012
Storyboard problem

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
ildandi is offline   0 Reply With Quote
Old Nov 7, 2012, 07:39 AM   #2
Reason077
macrumors 65816
 
Join Date: Aug 2007
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.
Reason077 is offline   0 Reply With Quote
Old Nov 7, 2012, 11:06 AM   #3
ildandi
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Can you help to understand how to set right structure!

Quote:
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



Quote:
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)


Quote:
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?


Quote:
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
ildandi is offline   0 Reply With Quote
Old Nov 8, 2012, 02:48 AM   #4
Reason077
macrumors 65816
 
Join Date: Aug 2007
Quote:
Originally Posted by ildandi View Post
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.

Quote:
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.

Quote:
Are you talking about StoryBoard?
The same rules apply regardless of whether you're using storyboards, regular .xibs, or [UIImage imageNamed:]
Reason077 is offline   0 Reply With Quote
Old Nov 8, 2012, 09:17 AM   #5
ildandi
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Great!!! now it's clear

Quote:
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?



Quote:
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?



Quote:
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
ildandi is offline   0 Reply With Quote
Old Nov 8, 2012, 09:25 AM   #6
Reason077
macrumors 65816
 
Join Date: Aug 2007
Quote:
Originally Posted by ildandi View Post
.. what name for iPhone5?
There's no difference for iPhone 5. It uses the same resources as iPhone 4 (i.e. "~iphone@2x")

Quote:
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.

Quote:
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.

Quote:
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.
Reason077 is offline   0 Reply With Quote
Old Nov 8, 2012, 09:28 AM   #7
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Just be sure you understand the difference between folders and groups in Xcode.
__________________
dejo is offline   0 Reply With Quote
Old Nov 9, 2012, 04:34 PM   #8
ildandi
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
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 is offline   0 Reply With Quote
Old Nov 12, 2012, 01:41 PM   #9
ildandi
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Can you help me understsand when use Folders and when Resources??

I think that I'm little confused about this

Thanks
ildandi is offline   0 Reply With Quote
Old Nov 12, 2012, 01:59 PM   #10
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Do you mean groups and not Resources?

Anyway, here's a blog article you might want to read: Xcode Groups vs. Folder References

P.S. Most current-day iOS Xcode projects no longer create a Resources group. Do yours have it? If so, what version of Xcode are you using?
__________________
dejo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Storyboard error hassoon iPhone/iPad Programming 0 Mar 15, 2013 06:19 PM
Storyboard and languages ildandi iPhone/iPad Programming 0 Nov 11, 2012 08:24 AM
Adding Buttons using Storyboard RagingGoat iPhone/iPad Programming 6 Oct 2, 2012 06:28 PM
Storyboard Question RagingGoat iPhone/iPad Programming 1 Sep 28, 2012 11:07 AM
Storyboard and custom root nashyo iPhone/iPad Programming 0 Aug 15, 2012 10:53 AM

Forum Jump

All times are GMT -5. The time now is 08:13 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC