Scrolling the table view after reloading uitableview
In my application, I want to append cells to the current tableview and have it scroll to the first added cell after the cells have all been appended. I have done the appended code by calling appending to the stack and calling [tableview reloadData]. However, I was wondering if there is a delegate or a notification that is sent by the uitableview that I can use to indicate when the table has been reloaded so that I can scroll to the selection. I originally thought viewDidAppear would be called but it is not. Any suggestions?
You could remove the reloadData
and use insertRowsAtIndexPaths:withRowAnimation:
instead to add the extra rows, afterwards scrollToRowAtIndexPath:atScrollPosition:animated:
can be used to scroll to a certain row. Adding rows this way is a bit more "cleaner" in my opinion instead of just calling reloadData, it is probably faster too.
When using insertRowsAtIndexPaths:withRowAnimation:
and the rows you're adding aren't visible, they will not be "loaded", once they are scrolled into view using the scroll method, they are "loaded".
Regarding the notificiation after the reloadData method has been completed, I'm pretty sure there's no notification available. The only notification of the UITableView is UITableViewSelectionDidChangeNotification
.
上一篇: 返回时取消选择表格视图行