I want to achieve tableViewCell
is selected then insert some rows. Select again then delete these rows. The method like below:
func animateRows(tableView: UITableView, insert: Bool, indexPaths: [IndexPath]) {
tableView.beginUpdates()
if (insert) {
tableView.insertRows(at: indexPaths, with: .fade)
} else {
tableView.deleteRows(at: indexPaths, with: .fade)
}
tableView.endUpdates()
print(tableView.contentSize)
tableView.reloadData()
print(tableView.contentSize)
}
This method works well. I want to get the contentSize
after insert or delete action ends. Then reset the tableView's content size. But the only way i found is after call tableView.reloadData()
the contentSize was updated. But feel not proper. Any other good solutions?
EDIT:
What are you doing with contentSize of a UITableView anyways?
I need the contentSize
to make the tableView
height fit the content. Actually my tableView is one subView of UIScrollView. I need the tableView
show all rows all the time. Then layout scrollView
contentSize
properly.