15

I am trying to write a macro to determine the device is 3.5 inch or 4 inch. Some thing similar below.

    #define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
    #define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )

Can someone help me. Please

Karthick
  • 382
  • 1
  • 3
  • 23

3 Answers3

56

you can detect iphopne 3.5 inch or 4 inch using bellow:-

#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE

you can check it using bellow method for example:-

     if (isiPhone5)
     {
           // this is iphone 4 inch
     }
     else
     {

           //Iphone  3.5 inch
     }

Please take a look of this link for you knew all about Macro for determine the device is 3.5 inch or 4 inch.

How to detect iPhone 5 (widescreen devices)?

Community
  • 1
  • 1
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • 1
    This macro is incorrect. For code: max = IS_iPhone5 ? 5 : 6; I receive 1 bacause you forgot to add bracers. Shorthand if-else format is uneccessary here. Below correct code: #define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568) – Szu Apr 14 '14 at 10:36
  • 1
    isn't bound orientation oriented in iOS8 ? – Sjoerd Perfors Oct 10 '14 at 13:18
  • @SjoerdPerfors you're right. I added a check to the orientation in an answer I posted on another question since answers aren't accepted on this question anymore: http://stackoverflow.com/a/35208438/159758 – DonnaLea Feb 04 '16 at 18:14
5

Mean something like this:

#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
Mikael
  • 3,572
  • 1
  • 30
  • 43
2

you can check if it is iphone 5 (4 inch) like this:

The iPhone 5's screen has a height of 568.

if ([ [ UIScreen mainScreen ] bounds ].size.height == 568)
jonypz
  • 1,515
  • 1
  • 20
  • 35