Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
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.
 
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:
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:
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 :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.