2

I'm building a chat interface. I'm using multiple types of tableView cells in UITableView. Table view cells are start flickering when new cell is added into tableView from reusablecell. I'm dequeuing tableview cells with following piece of code. How get scrolling smooth with out any flickering.

tableView.dequeueReusableCellWithIdentifier("MessageLessonTableViewCell") as! MessageLessonTableViewCell
Nirav D
  • 71,513
  • 12
  • 161
  • 183
chandra mohan
  • 327
  • 1
  • 4
  • 19
  • are you reloading tableView in your app ? – Pranav Jul 20 '16 at 05:31
  • @PranavGupte i'm adding new tableview cells in two methods. self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: animation) self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: true) – chandra mohan Jul 20 '16 at 05:32
  • and adding element datasource and using tableview.reloaddata() – chandra mohan Jul 20 '16 at 05:33
  • Both methods didn't help me much – chandra mohan Jul 20 '16 at 05:33
  • because use of tableView.reloaddata() several times cause flikering effect see this : http://stackoverflow.com/questions/15196927/reload-uitableview-with-new-data-caused-flickering – Pranav Jul 20 '16 at 05:35

1 Answers1

1

The main reason for flickering is that, tableView is getting data to be attached late in time. So when you scroll, it takes time to switch from one type of tableViewCell to another. Plus you might be doing DB operations in cellForRowAtIndexPath which delays in returning tbaleViewCell. For implementing Smooth scrolling refer this

Vishal Sonawane
  • 2,637
  • 2
  • 16
  • 21