UITableView has unwanted animation when calling reloadData

I have a UITableView, if I scroll the contents a bit and then call reloadData , a scroll animation appears in the table when the data is reloaded.

enter image description here

table setup in 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 } 

When the submit button is pressed, tableView.reloadData() called. Any ideas why this animation is happening? What can I do to stop him?

+4
ios uitableview swift
source share
2 answers

Before calling reloadData , you need to reset first and then reloadData .

  tableView.contentOffset = .zero 
0
source share

You can try reloading the tableview to execute QuestionAnimations : block:

 UIView.performWithoutAnimation { self.tableView.reloadData() } 
0
source share

All Articles