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

前端 未结 5 927
别那么骄傲
别那么骄傲 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:28

    Choose your xib file and change the Size attribute.

    enter image description here

    0 讨论(0)
  • 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").
    0 讨论(0)
  • 2020-12-09 06:34

    if your interface is using Storyboard:

    Open *.Storyboard with "Text Editor"

    and go the end bottom find <simulatedScreenMetrics key="destination" type="retina4"/>

    delete type="retina4"

    then it will be default size in 3.5"

    0 讨论(0)
  • 2020-12-09 06:38

    From what i have understand u want to create a table view which can be applicable to both iPhone 4 and 5. First thing first i havnt tried the Xcode 4.5, but the code

     CGRect fullScreenRect = [[UIScreen mainScreen] bounds];
     theTableView.frame = CGRectmake = (0,0,fullScreenRect.width,fullScreenRect.height);
    

    the fullScreenRect will return the bound of the current device whether its 3.5 or 5 inch. and u can set the height and width dynamically.

    Let me know if it worked..

    Cheers

    W

    0 讨论(0)
  • 2020-12-09 06:42

    BEWARE of setting the size attribute to "Retina 4 Full Screen" if you present actionsheets in your application. This solution actually sets the dimensions of the main Window to the dimensions of the iPhone 5. In my case, setting this affected display in the iPhone 4 when you try to show an action sheet because it will try to show it from below the viewable screen.

    The proper solution that works for all cases is to set the size to none and detect the screensize in the app delegate didfinishloading method and set the main window to that size or set the rootviewcontroller's view to that size. Actionsheets will work correctly.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.window.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);
    
    }
    
    0 讨论(0)
提交回复
热议问题