views:

48

answers:

2

Hi

In my application i need to get the correct image based on the device ipad/iphone4/iphone3 device.

for example

i have image name a.png(width 40,height 20) its for iphone3/ipod ,and if i give [email protected] (width 80,height 40) its for iphone4 ,

if i mentioned the code UIImage *myImage=[UIImage imageNamed:@"a.png"];

myImage contains (80*40) image if its iphone4 myImage contains (40*20) image if its ipod/iphone3

my question is how do i get the image for ipad(60*30) like above naming convention,

i tried giving a~ipad.png as a image name and its not working,

can u point me out where i am doing mistake.

and if i use the condition using [UIDevice currentDevice]; isIpod -> load(60*30) image otherwise load images for iphone/ipod its working fine.

but i need to get it work without using the condition, and using the naming convention like a.png for iphone/ipod [email protected] for iphone4 like wise for ipad,

Thanks in advance.

+4  A: 

There is no image naming convention for iPad, it's only for retina displays so that your images will appear crisp. If you want to support iPad then you need to create a separate layout for it (separate xib), even separate set of images in most cases because you were given a bigger layout.

You can, however, create a naming convention for yourself and pass the string name to a static function that will convert the name to an iPad / iphone depending on the device.

E.g.

[UIImage imageNamed: [MyAppUtils getImageName:@"a.png"]];

and inside the getImageName function, you can do your conversion (use the same name if iphone, else rename to something else)

Manny
A: 

I am using a "Resource Manager" that I developed first before creating any application. This Resource Manager can decide about the naming convention after loading the resource configuration files (mostly XML). This way everything is transparent to the programmer of the GUI, you only need to worry about creating the content :)

Istvan