collapsing a UITableView

Posted by Sage Washabaugh on Stack Overflow See other posts from Stack Overflow or by Sage Washabaugh
Published on 2012-06-20T21:12:02Z Indexed on 2012/06/20 21:16 UTC
Read the original article Hit count: 136

Filed under:
|
|
|

Hey everyone I made a UITableView in my app and when a cell is touched it expands the problem I am having is it does not collapse no matter what I have tried, I'm sure its something easy i just cant figure it out the only time it does collapse is when it another cell is tapped.

Here is my code:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

selectedCellIndexPath = indexPath;

[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];

if (selectedCellIndexPath) {
    selected = YES;
}

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

if(selectedCellIndexPath != nil  
   && [selectedCellIndexPath compare:indexPath] == NSOrderedSame)  
    return 150;

return 44;

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c