Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 15: tableView in Cell,tableView.contentSize.height don't fix, before iOS 14 is no problem #732

Open
Aviicii opened this issue Oct 14, 2021 · 3 comments

Comments

@Aviicii
Copy link

Aviicii commented Oct 14, 2021

**

  • Current solution: iOS 15 estimatedRowHeight set a larger height
  • if your UI cell's height may be 80 px
  • your estimatedRowHeight must set > 80
  • but the contentSize.height is not Accurate height

**

setData:

    tableView.reloadData()
    tableView.layoutIfNeeded()
    tableView.snp.updateConstraints { make in
        make.height.equalTo(tableView.contentSize.height)
    }

setUI:

    contentView.addSubview(tableView)
    tableView.snp.makeConstraints { make in
        make.top.left.right.equalToSuperview()
        make.height.equalTo(0)
        make.bottom.equalToSuperview().priority(.low)
    }

the code in iOS 15 don't work

QQ20211014-092826
BF07C540A51F3A233441F59EB1752E02
WX20211027-134458
WX20211027-134551

@Aviicii Aviicii changed the title AtableView in ACell, BtableView in BCell, they are height don't fix, if only tableView in Cell is no problem iOS 15: AtableView in ACell, BtableView in BCell, they are height don't fix, if only tableView in Cell is no problem Oct 14, 2021
@Aviicii Aviicii changed the title iOS 15: AtableView in ACell, BtableView in BCell, they are height don't fix, if only tableView in Cell is no problem iOS 15: AtableView in ACell, BtableView in BCell, they are height don't fix, if only tableView in Cell and before iOS 14 is no problem Oct 14, 2021
@Aviicii Aviicii changed the title iOS 15: AtableView in ACell, BtableView in BCell, they are height don't fix, if only tableView in Cell and before iOS 14 is no problem iOS 15: tableView in Cell,tableView.contentSize.height don't fix, before iOS 14 is no problem Oct 21, 2021
@Aviicii Aviicii closed this as completed Oct 27, 2021
@Aviicii Aviicii reopened this Oct 27, 2021
@wiince
Copy link

wiince commented Nov 2, 2021

Hi, this is a new feature of iOS15, you can set sectionHeaderTopPadding to 0 to avoid this happen, or add UITableView.appearance.sectionHeaderTopPadding = 0 as a common solution for your project.

@Aviicii
Copy link
Author

Aviicii commented Nov 2, 2021

Hi, this is a new feature of iOS15, you can set sectionHeaderTopPadding to 0 to avoid this happen, or add UITableView.appearance.sectionHeaderTopPadding = 0 as a common solution for your project.

WX20211102-161915

@wiince
Copy link

wiince commented Nov 2, 2021

I think you get the contentSize at the wrong time,

pls try this:

self.tableView.performBatchUpdates {
	self.tableView.reloadData()
} completion: { (_) in
	debugPrint(self.tableView.contentSize.height)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants