当我点击特定的单元格时,我正在尝试更新单元格大小。我的表在iOS 10.2中得到了完美的更新,但是当我在iOS 11上运行我的代码时,我的表格闪烁。我也在iOS 11中得到警告-[UIApplication application state] must be used from main thread.
所以,我有在调度队列中重新加载我的表但没有任何反应。我有多级XIB,就像我有一个单元格,其中我有一个表,它正在注册另一个单元,它会在点击时扩展。当高度扩展我的主表闪烁时,下面是我的代码示例。
func expandMessageTable(height : CGFloat,expendedRow:Int){
self.expandMessageHeight = height
self.msgExpRow = expendedRow
let row = cellMenuArr.index(of:"MessageXIB")
let path = IndexPath(row: row!, section: 0)
print(path)
homeTblView.reloadRows(at: [path], with: .fade)
}
下面是我用来重新加载单元格的精细工作代码 -
DispatchQueue.main.async(execute: {
UIView.performWithoutAnimation {
self.tableView?.beginUpdates()
let contentOffset = self.tableView?.contentOffset
self.tableView?.reloadRows(at: [IndexPath(row: j, section: 0)], with: .automatic)
self.tableView?.setContentOffset(contentOffset!, animated: false)
self.tableView?.endUpdates()
}
})
希望能帮助到你。