重新加载tableview部分没有滚动或动画 [英] Reload tableview section without scroll or animation

查看:106
本文介绍了重新加载tableview部分没有滚动或动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码重新加载tableView部分 -

I am reloading a tableView section using this code -

self.tableView.beginUpdates()
                self.tableView.reloadSections(NSIndexSet(index: 1), withRowAnimation: UITableViewRowAnimation.None)
                self.tableView.endUpdates()

仍然将行替换设置为动画,并且表格视图滚动到顶部。

Still the rows replacement is animated and the table view scrolls to the top.

如何确保不会将动画应用于section reload +阻止表格视图滚动。

How can I make sure that no animation will be applied to the section reload + prevent the table view from scrolling.

谢谢

推荐答案

试试这个:

    UIView.setAnimationsEnabled(false)
    self.tableView.beginUpdates()
    self.tableView.reloadSections(NSIndexSet(index: 1) as IndexSet, with: UITableViewRowAnimation.none)
    self.tableView.endUpdates()

这篇关于重新加载tableview部分没有滚动或动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆