iOS Tableview點擊cell 會往上跳

緣由:
UITableview有個估算行高功能,若是沒有設置tableView.estimatedRowHeight = 0,默認開啓,默認高度是44,也就是若是你實際行高和44誤差很大的話,每次reloadData就會先根據估算行高進行刷新而後再走heightForRow去獲取真正高度,就會視覺上就會產生跳一下的感受,tableView.estimatedRowHeight = 0設置爲0關閉這個功能就好了 
 
解決辦法一:刷新單個cell
 
解決辦法二:
self.tableView.estimatedRowHeight = 0
self.tableView.estimatedSectionHeaderHeight = 0
self.tableView.estimatedSectionFooterHeight = 0

 

相關文章
相關標籤/搜索