Empty white space above UITableView inside a UIView

前端 未结 8 1080
梦毁少年i
梦毁少年i 2020-12-13 13:53

I\'m trying to position a TableView inside my ViewController view but leaving a 44 height gap between the bottom of the navigation bar and the top of the table. I then wante

相关标签:
8条回答
  • 2020-12-13 14:21

    Just add this in you ViewDidLoad method

    self.automaticallyAdjustsScrollViewInsets = NO;
    
    0 讨论(0)
  • 2020-12-13 14:22

    You should not need to change the default setting for Extend Edges.

    Looks like the real problem is a blank table header view in your storyboard. It's showing in the screenshot you provided of your storyboard, right below the Enter Name view and right above the Prototype Cells view. Delete it.

    0 讨论(0)
  • 2020-12-13 14:24

    For Objective-C folks, add this in your ViewDidLoad method.

    [self.tableView setContentInset:UIEdgeInsetsMake(-20, 0, 0, 0)];
    
    0 讨论(0)
  • 2020-12-13 14:27

    My issues is, I set tableHeaderView as new UIView like this

    self.tableHeaderView = UIView(frame: .zero)
    

    Remove this line, the issue is gone. Try this:

    //self.tableHeaderView = UIView(frame: .zero)
    
    0 讨论(0)
  • 2020-12-13 14:29

    Try this one:

    self.tableView.contentInset = UIEdgeInsetsMake(-65, 0, 0, 0)
    
    0 讨论(0)
  • 2020-12-13 14:31

    change your table view style from grouped to plain

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