iOS 7 UITableView: How to remove space between navigation bar and first cell

前端 未结 15 2353
Happy的楠姐
Happy的楠姐 2020-12-04 07:15

Description of the problem: with iOS 7 in grouped UITableView there is a gap between the top of the table view and the first cell.

The strange part is th

相关标签:
15条回答
  • 2020-12-04 07:33

    For solve this problem make sure that you unchecked this field on ViewController:

    On ViewController >> Attibutes Inspector >> Layout (unchecked - Adjust Scroll View Insets)

    if this is not enough, try this on TableView, set Style to Plain:

    This will solve your problem

    0 讨论(0)
  • 2020-12-04 07:38

    If you are using a UITableView with grouped style and only 1 group, use plain style instead solve your problem.

    UITableViewController *tableViewController;
    tableViewController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
    
    0 讨论(0)
  • 2020-12-04 07:40

    I am working with Xcode 7.3.1, iOS9, and swift 2. I would like to share what worked for me:

    Just add this in you ViewDidLoad method

    self.automaticallyAdjustsScrollViewInsets = false;
    
    0 讨论(0)
  • 2020-12-04 07:42

    Starting in iOS 7, you automatically get a group header and some space. Compare your app to the Settings app and you'll see. You can work around it by telling the UITableView to set the header height as small as possible. See How to hide first group header.

    0 讨论(0)
  • 2020-12-04 07:43

    The answer was very funny for me and my team, and worked like a charm

    • In the Interface Builder, Just move the tableview under another view in the view hierarchy.

    REASON:

    We observed that this happens only for the First View in the View Hierarchy, if this first view is a UITableView. So, all other similar UITableViews do not have this annoying section, except the first. We Tried moving the UITableView out of the first place in the view hierarchy, and everything was working as expected.

    0 讨论(0)
  • 2020-12-04 07:43

    Go to the attributes inspector of the View Controller by selecting the xib or the controller in Storyboard. Uncheck the Adjust Scroll View Insets in Layout. It will solve the problementer image description here

    0 讨论(0)
提交回复
热议问题