I know it is possible to set the height of all rows in a UITable but is it possible to set one row to be bigger than the others. For example when the user touches on the cell with 2 fingers I want the cell to expand and show a description. But only that cell. Is that possible without overlapping the cells below it?
+1
A:
Use the UITableViewDelegate method heightForRowAtIndexPath
Say that your data model stored objects that have a height
property:
- ( void ) changeHeightForRowAtIndexPath: ( NSIndexPath *) indexPath ( NSInteger ) height {
[ myData objectAtIndex: indexPath.row ].height = height;
[ myTableView reloadRowsAtIndexPaths: [ NSArray arrayWithObject: indexPath ] withRowAnimation: UITableViewRowAnimationNone ];
}
Jacob Relkin
2010-05-04 17:33:36
But I won't be able to change the height of the row when I like? Only when the TableViewController "asks" for it
Jonathan
2010-05-04 17:49:28
Just call `reloadRowsAtIndexPaths` with a one-element `NSArray`.
Jacob Relkin
2010-05-04 18:05:55
You want to persist cell height?
Jacob Relkin
2010-05-04 18:19:52
Jonathan: Just return the correct height in `-heightForRowAtIndexPath:` and you'll be all set.
Jeff Kelley
2010-05-04 18:20:00
+1
A:
Override this method - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
.
Aleksejs
2010-05-04 18:29:46