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

Discussion in 'iOS Programming' started by moonman239, Feb 18, 2014.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    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.
     
  2. moonman239, Feb 18, 2014
    Last edited: Feb 18, 2014

    moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #2
    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
    
     
  3. moonman239, Feb 18, 2014
    Last edited: Feb 18, 2014

    moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #3
    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
    
     
  4. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #4
    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 :)
     
  5. amorya macrumors 6502

    Joined:
    Jun 17, 2007
    #5
    How can you know what the user has looked at?
     

Share This Page