How to make a uitableview in interface builder compatible with a 4 inch iPhone

前端 未结 5 941
别那么骄傲
别那么骄傲 2020-12-09 06:02

How do I make a uitableview in interface builder compatible with 4 inch iphone5, and the older iPhone 4/4s?

There are three options in Xcode 4.5:

  • Freef
5条回答
  •  情歌与酒
    2020-12-09 06:34

    Settings like choosing from "freeform", "Retina 3.5" or "Retina 4" in Interface Builder are in the "Simulated metrics" section of the right panel (note the emphasis added).

    This means that they are only used to show you how the view will look when displayed at those dimensions. Typically you use this to know at design time what space you will have to layout your views. But the UIView of a UIViewController is always resized when displayed on screen at the end.

    For example if you know that you will have a status bar and a NavigationBar at the top, and a TabBar at the bottom, you will have less space to organize your remaining view on the screen, so selecting these in the "Simulated Metrics" section of the panel will help you see which space you have in the view and avoid placing elements at say y=460 that will go offscreen at runtime due to these NavBar and TabBar.

    But at the end, the UIViewController will resize its view so that it takes the maximum space available, moving the subviews according to the AutoresizingMask properties (the struts & springs you can configure in the Size Inspector pane in IB).

    In conclusion, the only thing you have to do is:

    • Prefer choosing the "Retina 3.5" simulated metric for your view to see in Interface Builder the smallest size you may have when this view is displayed (helping you avoid to placing views and controls in a portion of you screen that will be only visible in 4" screens but not on 3.5" screens and desining your view by keeping in mind the smallest common zone)
    • Configure your AutoResizing Masks correctly (or use AutoLayout and constraints if you plan to release your app for iOS6 only and not iOS4 or iOS5) so that your views will me rearranged correctly when the screen is higher (Retina 4").

提交回复
热议问题