简体   繁体   English

UITableView中的reloadSections跳到顶部

[英]reloadSections in UITableView bounces to top

In my UITableView after certain change to model i am trying to load the specific section in where my cells are getting loaded according to the model. 在对模型进行某些更改后的UITableView ,我试图根据模型在加载单元格的位置加载特定部分。 But whenever the change happens there comes error with animation, which is like bouncing to top or down. 但是,只要发生更改,动画就会出现错误,就像跳到顶部或向下一样。 how do i resolve it? 我该如何解决? So far nothing worked. 到目前为止,没有任何效果。 This is how i am updating my section after api response: 这是我在api响应后更新我的部分的方式:

DispatchQueue.main.async {

                    self.tableView.beginUpdates()
                    self.tableView.reloadSections(indexSet, with: .none)
                    self.tableView.endUpdates()

                }

Because i had images of different sizes my tableview could not adjust the height calculation while reloading the table. 因为我有不同大小的图像,所以在重新加载表格时, tableview无法调整高度计算。 So i have tried to pre calculate the previous height and adjust it to the new one. 因此,我尝试了预先计算先前的高度并将其调整为新的高度。 While implementing the thing it came to my mind that i can update the table from my cell and calling layoutIfNeeded would do the trick. 在执行该操作时,我想到可以从单元格更新表并调用layoutIfNeeded可以解决问题。 So eventually it worked. 因此最终成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM