开发者

Scrolling the table view after reloading uitableview

开发者 https://www.devze.com 2022-12-10 05:40 出处:网络
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

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 reloadD开发者_高级运维ata]. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消