0

I am developing an universal app where I have given a background image for a UIView using the following code.

UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"backImage.png"];

[self.view addSubview:imgView];
[self.view sendSubviewToBack:imgView];

I have created the following images and added to the project,

backImage.png

backImage@2x.png

backImage-Portrait~ipad.png

backImage-Portrait@2x~ipad.png

backImage-Landscape~ipad.png

backImage-Landscape@2x~ipad.png

But it does not seem to take the correct images.

It works fine when I run the app on iphone (I mean it takes the backImage.png and backImage@2x.png accordingly) but when I run the app on ipad it does not use the ipad images, it still uses the iphone images. Can anyone please tell what must be going wrong.

Thanks in advance.

Neha Dangui
  • 597
  • 2
  • 13
  • 28
  • What exactly does it do? What device are you running on? Please share an image of what is happening. – Popeye Jan 28 '14 at 08:09
  • It works fine when I run the app on iphone (I mean it takes the backImage.png and backImage@2x.png accordingly) but when I run the app on ipad it does not use the ipad images, it still uses the iphone images. – Neha Dangui Jan 28 '14 at 08:14
  • Well that needs adding to you question then please. How are we meant to know that without you telling us. Please provide all information – Popeye Jan 28 '14 at 08:15

2 Answers2

0

I may be wrong, but I don’t think UIImage will know whether to load the ‘portrait' or ‘landscape' version of an image, much less change them dynamically when you rotate your interface. I think you’re expecting a lot more magic then there is.

Those conventions work in the app launch snapshot, but I think that’s the extent of it?

Wil Shipley
  • 9,343
  • 35
  • 59
0

You need to detect in your code what type of device is being used, and depending on that, choose the appropriate image.

See here: iOS detect if user is on an iPad

Community
  • 1
  • 1
cohen72
  • 2,830
  • 29
  • 44