I have a UITableview
with section and index title. When user click on a cell a option view of height 42 gets display in that cell. To display that option I reload the cell. But section header is also getting updated. That gives bizarre animation. How to reload only cell,without getting called for other delegate method like heightForHeaderInSection
and viewForHeaderInSection
.
2
votes
3 Answers
2
votes
I think you should only update the particular row for indexPath, try the code below
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[tableView endUpdates];
}
It might help you.
Cheers.
2
votes
2
votes
There are several methods for reloading the tableview.
To reload whole section including section's cell.
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
Example:
[tableVIewContent reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
To reload single/multiple cells
- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath > )indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Example:
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
To reload whole tableview.
- (void)reloadData;
// reloads everything from scratch. redisplays visible rows. because we only keep info about visible rows, this is cheap. will adjust offset if table shrinks
begin/endupdate
to reload cell – EI Captain v2.0