1

static cell style:grouped enter image description here

enter image description here

There is always a gap between the group and the navigation bar(I use red mark in the picture)

None of the following methods work: enter image description here

Is there any way to cancel the spacing between the group and the navigation bar, and set the direct spacing between the group and the group to 0 ?

2
  • 1
    Did you tried to set value to something small like 0.1 or 1 instead of 0 ?
    – Ptit Xav
    Jun 21, 2022 at 16:56
  • amazing!!!I tried various methods for one day, and you solved my problem in one sentence!!!thanks very very very very much Jun 22, 2022 at 3:02

2 Answers 2

0

I have found a solution to the direct distance between the group and the navigation bar, like this:

self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];

According to the help of netizens, I understand that I only need to set the height of the header and footer to 0.1 instead of 0

0

This behavior was introduced in iOS 15: https://developer.apple.com/videos/play/wwdc2021/10059?time=438 The added sectionHeaderTopPadding can be removed (at least for plain tables) by setting:

if #available(iOS 15.0, *) {
    UITableView.appearance().sectionHeaderTopPadding = CGFloat(0)
}

// Or for a specific table:
if #available(iOS 15.0, *) {
    tableView.sectionHeaderTopPadding = .leastNormalMagnitude  // if 0 doesn't work
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.