How do you scroll to the bottom of a tableView if you don't know how many rows it has?
I know that we can scroll to the bottom of the UITableView in a regular UITableViewController by using:
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPa开发者_开发问答th atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
Where indexPath can be found by doing a count of how many objects are there in the array of objects. However, in three20.. how do we do the same thing as we don't have the array of objects in the table?
I don't know if there's something that makes three20 different, but this should work in any UITableViewController subclass:
- (void)scrollToBottom {
NSInteger section = [self.tableView numberOfSections] - 1;
NSInteger row = [self.tableView numberOfRowsInSection:section] - 1;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
精彩评论