Cells disappearing during animation of UITableView

拥有回忆 提交于 2019-12-03 14:12:54

I just heard back from the Apple Developer Technical Support team regarding this issue, and here's their response verbatim (emphasis mine):

Hello Nicolas,

Thank you for contacting Apple Developer Technical Support (DTS).

The behavior and resulting limitations you describe are by design.

If you believe an alternative approach should be considered by Apple, we encourage you to file an enhancement request with information on how this design decision impacts you, and what you’d like to see done differently.

Although there is no promise that the behavior will be changed, it is the best way to ensure your thoughts on the matter are seen by the team responsible for the decision.

Best Regards,

Apple Developer Technical Support

It seems we're just stuck with having to use a simple call to either tableView.setContentOffset(_:animated:) or tableView.scrollToRow(at:at:animated:).

Ok, I'll try to propose my version, though I can't check it, since I don't see your project. I didn't try to compile it, so it may have mistakes.

var navFrame = self.navigationController?.navigationBar.frame
navFrame.origin.y = isEditing ? -navFrame.size.height : 0

var frame = tableHeaderView.frame
frame.size.height = tableHeaderView.headerHeight(forEditing: isEditing)

UIView.animate(withDuration: 0.3, animations: {
    if isEditing{
        let point = CGPoint(x: 0, y: -self.topLayoutGuide.length)
        self.tableView.contentOffset = point
    }

    self.navigationController?.navigationBar.frame = navFrame

    tableHeaderView.frame = frame

    self.view.layoutIfNeeded()
}) { [weak self](completed:Bool) in
    //Do stuff
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!