-2

From prefix.pch I want to return 4 if iPhone is iPhone 4 or lower and 5 if iPhone is iPhone 5 or more...

I know how to know the height

#define iPhoneHeight [[UIScreen mainScreen] bounds].size.height

Based on this, I get height, but I want to return 4 or 5.

Any idea how to get this done?

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276

2 Answers2

0

Wouldn't this help ?

    #define isIPhone4or5 CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size,CGSizeMake(640, 1136)) ? 5 : 4
Chamira Fernando
  • 6,836
  • 3
  • 23
  • 23
  • no.. I need in reply as 4 or 5 as I am setting images programmatically... so I will have is `mainBackground.image = [UIImage imageNamed:[NSString stringWithFormat:@"bg_Categories_iPhone%d.png", iPhone4Or5]];` – Fahim Parkar Nov 04 '13 at 08:29
  • Then its easy it will be like this #define isIPhone4or5 CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size,CGSizeMake(640, 1136)) ? 5 : 4 – Chamira Fernando Nov 04 '13 at 09:07
0

You can compare height with value in points for 4 inch display like this:

#define iPhone4Or5 [[UIScreen mainScreen] bounds].size.height == 568 ? 5 : 4
Zend
  • 29
  • 1
  • 2