I use
func insertRowsAtIndexPaths(indexPaths: [NSIndexPath],
withRowAnimation animation: UITableViewRowAnimation)
method to insert a new Row in a table. But it appears from Top of the UITableView
(by default).
I couldn't find any option to insert rows from the bottom of the table, like on screenshot:
I tried use the UIEdgeInsetsMake
:
self.tableView.contentInset = UIEdgeInsetsMake(tableView.frame.height,0,0,0)
but it broke all design when I scroll the table.
My question is: how to insert a new rows from bottom of the table?
UPD: It should looks like table moves from a keyboard View to NavigationBar when new row is added.
UPD2: Here is what I want: http://recordit.co/JoR7xuvvpG
I did it with the help of
self.tableView.contentInset = UIEdgeInsetsMake(tableView.frame.height,0,0,0)
But contentInset adds a big white field above the rows and when I scroll down it hides added rows. Looks like they is hiding under the keyboardView. I want to prevent it.
Swift 3
TableView.beginUpdates()
let indexPath:IndexPath = IndexPath(row:(self.yourArray.count - 1), section:0)
TableView.insertRows(at: [indexPath], with: .left)
TableView.endUpdates()
TableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
func insertRowsAtIndexPaths(indexPaths: [NSIndexPath],
withRowAnimation animation: UITableViewRowAnimation)
It is the method for appending the rows. For inserting rows at bottom you need to give indexpath of the last row.
For Example:
var IndexPathOfLastRow = NSIndexPath(forRow: self.array.count - 1, inSection: 0)
self.tableView.insertRowsAtIndexPaths([IndexPathOfLastRow], withRowAnimation: UITableViewRowAnimation.Left)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With