调用 reloadData 时 UITableView 有不需要的动画 [英] UITableView has unwanted animation when reloadData is called
本文介绍了调用 reloadData 时 UITableView 有不需要的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 UITableView,如果我稍微滚动一下内容,然后调用 reloadData
表格似乎在重新加载数据时执行滚动动画.
I have a UITableView, if I scroll the content a little and then call reloadData
the table appears to do a scrolling animation when the data is reloaded.
在viewDidLoad
中调用的表设置:
func setupTableView() {
tableView.register(UINib(nibName: "AnswerCell", bundle: nil), forCellReuseIdentifier: "AnswerCell")
tableView.register(UINib(nibName: "QuizDescription", bundle: nil), forCellReuseIdentifier: "QuizDescription")
tableView.register(UINib(nibName: "QuestionNumberCell", bundle: nil), forCellReuseIdentifier: "QuestionNumberCell")
tableView.tableFooterView = UIView()
tableView.estimatedRowHeight = 135
tableView.rowHeight = UITableViewAutomaticDimension
tableView.delegate = self
tableView.dataSource = self
}
当提交按钮被按下时 tableView.reloadData()
被调用.任何想法为什么会发生这个动画?我该怎么做才能阻止它?
When the submit button is pressed tableView.reloadData()
is called. Any ideas why this animation is happening? What can I do to stop it?
推荐答案
您可以在 performWithoutAnimation: 块:
UIView.performWithoutAnimation {
self.tableView.reloadData()
}
这篇关于调用 reloadData 时 UITableView 有不需要的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文