iOS 11 UITableView bug

*爱你&永不变心* 提交于 2019-12-02 18:41:22

In iOS 11, all the estimated UITableView properties (estimatedRowHeight, estimatedSectionHeaderHeight, and estimatedSectionFooterHeight) default to UITableViewAutomaticDimension.

I see that for your cells that's fine as you're returning UITableViewAutomaticDimension in heightForRow. For your section headers and footers however you aren't utilizing the auto-sizing. I would try disabling all the auto-sizing behavior in your headers/footers by setting estimatedSectionHeaderHeight, and estimatedSectionFooterHeight to 0.

Source: iOS 11 Floating TableView Header

Try this workarround, assuming your IBOutlets and variables are not privates in StandardHeaderView.swift:

    func toggleSection(section: SectionType) {
    self.sectionsOpened[section] = !self.sectionsOpened[section]!

    let sectionIndex = self.sections.index(of: section)!

    let indexPath = IndexPath(row: 0, section: sectionIndex)

    UIView.animate(withDuration: 0.25) {
        self.tableView.reloadRows(at: [indexPath], with: .automatic)
        if let headerView = self.tableView.headerView(forSection: sectionIndex) as? StandardHeaderView {
            headerView.configWith(title: headerView.headerTitleLabel.text!, isOpen: self.sectionsOpened[section]!, selector: headerView.selector)
        }

        self.tableView.scrollToRow(at: IndexPath(row: 0, section: sectionIndex), at: .top, animated: true)
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!