1
可折叠节:[Assert]无法为preReloadFirstVisibleRow(0)确定新的全局行索引
我正在UITableViewController中实现可折叠的节标题。 这是我确定每个部分要显示多少行的方法: override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.sections[section].isCollapsed ? 0 : self.sections[section].items.count } 有一个结构,其中包含用于“ isCollapsed”的部分信息。 这是我如何切换他们的状态: private func getSectionsNeedReload(_ section: Int) -> [Int] { var sectionsToReload: [Int] = [section] let toggleSelectedSection = !sections[section].isCollapsed // Toggle collapse self.sections[section].isCollapsed = toggleSelectedSection if self.previouslyOpenSection != -1 …