0

I am using AccordionTableView in my swift. Now on each time i added the new accordion cells. The newly added value always comes down the previous values. I need to show them above all the previous values.i am stocked how to do?Can anybody please give me a guide?

Sam
  • 449
  • 2
  • 9
  • 18

2 Answers2

0

You need to try

yourArrayForTableView.insert(data, atIndex: 0)
tableView.beginUpdates() 
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: .Automatic)                                         
tableView.endUpdates()

Here new data is added to first row of first section in the tableview.

saroj raut
  • 834
  • 8
  • 16
0

Let someArray be the datasource for your tableView, then you can insert a new row at index 0 like this:

someArray.insert(newDataValue, at: 0)
tableView.reloadData()
KSR
  • 1,699
  • 15
  • 22