Grouped UITableView has 20px of extra padding at the bottom

前端 未结 12 1120
长发绾君心
长发绾君心 2020-12-23 09:34

Grouped table views seem to have extra padding on the bottom in iOS 6 (iOS 5 does not have it), but I can\'t find any documentation that suggests this is correct / expected

相关标签:
12条回答
  • 2020-12-23 10:03

    Use the bounces property of UIScrollView:

    [yourTableView setBounces:NO];
    

    This will remove what seems to be an extra padding at the top and bottom of your UITableView. Actually, it will just disable the tableview's scrollview to scroll past the edge of the content.

    0 讨论(0)
  • 2020-12-23 10:05

    You can use contentInset to compensate the 20px extra bottom margin:

    tableView.contentInset = UIEdgeInsetsMake(0, 0, -20, 0);
    
    0 讨论(0)
  • 2020-12-23 10:11
    -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
       return 0.01;
    } 
    

    It's work for me

    0 讨论(0)
  • 2020-12-23 10:12

    Following code works for me

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
        return 0;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
        return 0;
    }
    
    0 讨论(0)
  • 2020-12-23 10:15

    Recently, I found this issue, and followed the solutions posted above, but all of them doesn't work. In my case, I have a section header with dynamic height. Inspired by the above solutions, I put following code, and problem solved. I hope this can help.

    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return UIView()
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.1
    }
    

    and config tableView's header and footer like this:

    tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 0.1))
    tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 0.1))
    
    0 讨论(0)
  • 2020-12-23 10:15

    Swift 5

     tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: .leastNormalMagnitude))
    
    0 讨论(0)
提交回复
热议问题