Is it better to build separate views for the different screen sizes for the height of the iPhone. Or is it better to creat a #define IS_IPHONE5 and adjust the view's code based on the hight of the phone? Any other ideas would be appreciated.
-
One good answer is here http://stackoverflow.com/questions/12396545/ios-6-apps-how-to-deal-with-iphone-5-screen-size and ... – cdub Oct 02 '13 at 07:40
-
the even better one is here http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution – cdub Oct 02 '13 at 07:40
3 Answers
Have you thought about using Auto Layout? It's the Apple-recommended way to do this.
You can find some posts online bashing Auto Layout. You shouldn't be discouraged by them, because from what I've seen they can mostly be divided into 2 groups:
- incorrect understanding of Auto Layout by the authors,
- poor Auto Layout implementation in Interface Builder in Xcode 4 (it's gotten a lot better in Xcode 5).

- 8,966
- 4
- 28
- 46
Using Auto layout is great option. Other then this you should create different views and use them depending on device and screen.

- 14,377
- 4
- 45
- 54
-
3It not a good idea to use different views for different screen sizes. Even with the old auto resize mask you can adjust your view to 4" devices. Maintaining different view for different screen size can become a lot of work. What if Apple introduces an other screen size, you will then need to support a third view. – rckoenes Oct 01 '13 at 08:32
-
Yup, you are right, That's why I said Auto Layout is great option. But if some body is not good and don't want to use that, he can go for different views. – Adnan Aftab Oct 01 '13 at 09:37
Creating different views for the different device screen resolutions is not a good idea. You should try to avoid constants when it comes to screen dimensions. If Apple decided to bring out a 6" phablet tomorrow with a different resolution you'd have to update your app and create an entirely new view for that resolution.
If you no longer have to support iOS5 then you should definitely go for auto layout. Take a look at this Ray Wenderlich tutorial to better understand auto layout:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
If you still need to support iOS5 then go with auto-resizing masks (the above tutorial also explains auto-resizing in short), it has its limits but you can correct this in viewDidLayoutSubviews in UIViewControllers and layoutSubviews in UIViews.

- 1,152
- 8
- 13