How to detect if the device is an iPhone 5
The iPhone5 introduced a new resolution to support in our iOS applications. The IPhone 5 resolution is 640x1136px at 4 inch screen, which makes it more elongated than in previous devices.
You may want to detect if the application is being used from an iPhone 5 and change the behavior of an element.
There are some ways to do, this is one of them:
1 | #define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568) ? NO : YES) |
We have defined a constant that will help us to detect the resolution of the iPhone 5. In our code we’ll just use an if block to act accordingly.
1 2 3 4 5 6 7 8 | if (IS_IPHONE5) { // The app is running on iPhone 5 } else { // Not an iPhone 5 } |
0 Comments