Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView , Scroll to bottom on reload?

I have a UITableView with cells that are dynamically updated. Everything works fine apart from when tableview.reload is called (see below) to refresh the cells in the table I would like the table to scroll to the bottom to show the new entries.

- (void)reloadTable:(NSNotification *)notification {     NSLog(@"RELOAD TABLE ...");     [customTableView reloadData];     // Scroll to bottom of UITable here .... } 

I was planning to use scrollToRowAtIndexPath:atScrollPosition:animated: but then noticed that I don't have access to an indexPath.

Does anyone know how to do this, or of a delegate callback that I could use?

like image 524
fuzzygoat Avatar asked Feb 25 '11 00:02

fuzzygoat


1 Answers

Use:

NSIndexPath* ipath = [NSIndexPath indexPathForRow: cells_count-1 inSection: sections_count-1]; [tableView scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated: YES]; 

Or you can specify the section index manually (If one section => index=0).

like image 121
Max Avatar answered Sep 28 '22 06:09

Max