Sean Cook Sean Cook - 3 months ago 5x
Swift Question

Swift scroll to bottom of table that has only blank sections

I am trying to scroll my table to the bottom every time a new section is added. They section may or may not have any rows but it still needs to scroll to the bottom. Any way to do this?


You may try something like this:

func scrollToBottom() {
    let bottomOffset = CGPoint(x: 0, y: tableView.contentSize.height - tableView.bounds.size.height + tableView.contentInset.bottom);
    tableView.setContentOffset(bottomOffset, animated: true)