iOS How do I tell my app to display the next few table view cells?

moonman239

macrumors 68000
Original poster
Mar 27, 2009
1,521
22
There is a table view in a view controller. This table view's content is loaded dynamically. There are some cells that, due to space constraints, are not being displayed in the view. I don't want the user to scroll down. I want the app to skip to the last few cells once it can verify that the user looked at all of the content that was already presented in the table view.
 

moonman239

macrumors 68000
Original poster
Mar 27, 2009
1,521
22
I am approaching a solution. Here's the code I have so far:

Code:
@implementation UITableView (displayOtherCells)
-(void)displayOtherCells
{
    
    NSArray *visibleCells = [self visibleCells];
    for (NSInteger i = [visibleCells count]; i < [self numberOfRowsInSection:1]; i++) {
        NSIndexPath *indexPathOfCell = [NSIndexPath indexPathForRow:i inSection:1];
        UITableViewCell *currentCell = [[self dataSource] tableView:self cellForRowAtIndexPath:indexPathOfCell];
    }
}
@end
 
Last edited:

moonman239

macrumors 68000
Original poster
Mar 27, 2009
1,521
22
OK, here's my untested solution:

Code:
@implementation UITableView (displayOtherCells)
-(void)displayOtherCells
{
    
    NSArray *visibleCells = [self visibleCells];
    for (NSInteger i = [visibleCells count]; i < [self numberOfRowsInSection:0]; i++) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
        [self scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
    }
}
@end
 
Last edited:

ianray

macrumors 6502
Jun 22, 2010
452
0
@
It is odd that you're calling
Code:
scrollToRowAtIndexPath:atScrollPosition:animated:
in a loop.

I would expect your solution to involve calculating a reasonable value of indexPath, and then scrolling to it.

Hope that helps :)