Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 views
in Technique[技术] by (71.8m points)

objective c - Naming convention for iPhone 5 images?

I am working on an app that would be for iPhone 5 and lower.

for images I am using this code

CGRect mainFrame = [[UIScreen mainScreen] bounds];

int imgIndex = arc4random() % 10 + 1;

if(mainFrame.size.height > 480)
    [pBackgroundImageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"dreams 1136x640 %d.jpg",imgIndex]]];
else
    [pBackgroundImageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"dreams_960x640_%d.jpg",imgIndex]]];

but I am not satisfied with it.

is there any specific naming convention for iphone 5 images?

Thanks in advance Mano

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

[email protected] this would be the launch image you need, you need to add -568h@2x to the end of all your iPhone 5 images, but there have been issues with the naming convention.

I found doing it like this has helped.

   [pBackgroundImageView setImage:[UIImage imageNamed:(IS_PHONE5()) ? @"[email protected]" : @"myimage.png"]];

The issue is it doesn't pick the -568h@2x up but this is the way it should be. to get the IS_PHONE5 variable add

   #define IS_PHONE5() ([UIScreen mainScreen].bounds.size.height == 568.0f && [UIScreen mainScreen].scale == 2.f && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

Thought this may help anyone wondering about supporting high resolution phones and iPhone 5

Supporting high resolution and iPhone 5


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...