Space Between Sections in UITableview

前端 未结 11 2107
醉酒成梦
醉酒成梦 2020-12-08 12:37

I need to reduce the space between two sections ofUITableView. I looked at this question but the solution doesn\'t allow for my custom header view because it c

相关标签:
11条回答
  • 2020-12-08 13:34

    I think you can solve this by adjusting the footer view height to its min: in Storyboard or XIB.enter image description here

    I don't know what you have written in your code for footer height. Sorry if I am wrong.

    Possible duplicate of Hide footer view in UITableView

    0 讨论(0)
  • 2020-12-08 13:35

    This also may help :

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.sectionHeaderHeight = UITableViewAutomaticDimension
    }
    
    0 讨论(0)
  • 2020-12-08 13:36

    For Swift 3

    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return CGFloat.leastNormalMagnitude
    }
    
    0 讨论(0)
  • 2020-12-08 13:37

    For Swift 4+ you need to implement these two methods

    extension MyViewController : UITableViewDelegate {
    
        func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
            return CGFloat.leastNormalMagnitude
        }
    
        func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
            return UIView()
        }
    
    }
    
    0 讨论(0)
  • 2020-12-08 13:41

    TableView Delegate methods doesn't effect with float value is 0.0f. Try giving a value greater than that.

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
        return 0.00001f;
    }
    
    - (UIView*)tableView:(UITableView*)tableView
    viewForFooterInSection:(NSInteger)section {
        return [[UIView alloc] initWithFrame:CGRectZero];
    }
    
    0 讨论(0)
提交回复
热议问题