Dear list,

I'm trying to construct a UITableViewCell with what is essentially a disclosure 
triangle on it.  When that's tapped, the cell expands to show additional 
information.  I currently hack this with code along these lines:

    NSArray *cellPaths = [tableView indexPathsForVisibleRows];
    [UIView animateWithDuration:0.3
                     animations:^ ()
     {
         MyCustomCell *cell = [tableView cellForRowAtIndexPath:indexPath];
         NSUInteger minRow = [indexPath row];
         BOOL d = ![cell disclosed];
         [cell setDisclosed:d];
         [disclosures setObject:[NSNumber numberWithBool:d] forKey:[cell 
statName]];
         for (NSIndexPath *p in cellPaths)
         {
             if ([p row] > minRow)
             {
                 MyCustomCell *c = [tableView cellForRowAtIndexPath:p]
                 [c setFrame:CGRectMake([c frame].origin.x, d ? [c 
frame].origin.y + kDisclosureOffset : [c frame].origin.y - kDisclosureOffset, 
[c frame].size.width, [c frame].size.height)];
             }
         }
         
     }
                     completion:^ (BOOL finished)
     {
         [tableView reloadRowsAtIndexPaths:cellPaths 
withRowAnimation:UITableViewRowAnimationNone];
     }];

This for the most part works well except for one case – collapsing the cells.  
When this happens, the table view does not have cells for the rows that are not 
yet visible, but become visible as the cell collapses.  Because of this, a 
blank area comes into view at the bottom of the table view, and then flashes as 
it gets replaced by the newly generated rows.

I've tried using cellForRowAtIndexPath: to grab the cells off the bottom, but 
these come back as nil, as the table view doesn't think it needs to show them.  
The only other thing I can conjor in my mind is to call something similar to 
the data source method directly to construct cells myself, add them to the TV, 
animate them in, remove them and reload the table view.  However, this does not 
solve one final issue – what happens when the table view is scrolled near to 
the bottom and there are no cells to add.

If anyone could recommend a good way forward here, I'd be appreciative.

Thanks

Tom Davie


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to