I want to sort UITableViewCell
's from bottom to top in UITableView
. Is there a way to do that in Swift? Here is another question like this in Obj-C;
How to position UITableViewCell at bottom of screen?
I tried the @replman's answer but it didn't work well.
Anyway, I think I should explain more detailed. Let say we have a UITableView
which has 1 cell. When we run, the cell shows up at the bottom of the screen. When we add second cell, then second cell slides up at the bottom of the tableView
and first cell is just above it.Just like whatsapp messenger.
Here is a nice visual that I took from the question above.
+----------------+ +----------------+ +----------------+
| | | | | |
| | | | | |
| | | | | |
| | | | | +------------+ |
| | | | | | cell 1 | |
| | | | | +------------+ |
| | | +------------+ | | +------------+ |
| | | | cell 1 | | | | cell 2 | |
| | | +------------+ | | +------------+ |
| +------------+ | | +------------+ | | +------------+ |
| | cell 1 | | | | cell 2 | | | | cell 3 | |
| +------------+ | | +------------+ | | +------------+ |
+----------------+ +----------------+ +----------------+
I would be glad if someone help.
SOLUTION:
First, flip
tableView
andtableViewCell
.Then load cells in reverse. It worked fine for me. For a little bit more information, check out this answer; https://stackoverflow.com/a/28435207/1404324