UITableView scrollToRow no longer works on iOS 11 right after adding a new row

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
});

Adding a small delay is working in my case.


Accepted answer in Swift 4 syntax

let deadlineTime = DispatchTime.now() + .seconds(1)
                DispatchQueue.main.asyncAfter(deadline: deadlineTime) {
                    self.tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
                }