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?
Asked
Active
Viewed 91 times
0
-
1insert the new data to first index of the array, then it will show on first? – Tj3n Dec 08 '16 at 03:59
-
try `yourArrayName.insert(newItem, at: 0)` – Joe Dec 08 '16 at 04:00
-
what does new element means? – Sam Dec 08 '16 at 04:05
-
`newItem` is your `data` that you inserting to your `tableViewCell` and `reload` your `tableview` – Joe Dec 08 '16 at 04:16
-
Possible duplicate of [How to reload and animate just one UITableView cell/row?](http://stackoverflow.com/questions/5418655/how-to-reload-and-animate-just-one-uitableview-cell-row) – William Hu Dec 08 '16 at 04:22
2 Answers
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