I wrote:
#define IS_IPHONE_5 ([UIScreen mainScreen].bounds.size.height == 568.0)
#ifdef IS_IPHONE_5
#define SCREEN_HEIGHT 568
#else
#define SCREEN_HEIGHT 480
#endif
but it always return that device is iPhone 5… What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your
IS_IPHONE_5macro is just fine. You can do things like this:At compile time this code will be converted to:
The problem is your
SCREEN_HEIGHTmacros. The whole#ifdefblock will be evaluated at compile time. Since you did defineIS_IPHONE_5, theSCREEN_HEIGHTwill always be set to 568.You want a runtime determination of the screen height. You can get this from: