I created a custom UITableViewCell. Registered it like below
When an imageView pressed inside of that cell then I refresh the data and reload the cell only not all tableView. But there is a weird problem which is whenever I reload the cell then a UILabel inside starts to shrink in every reload. This is how I reload the data
And this is how the cell size is calculated
Code:
[self.mainTableView registerNib:[UINib nibWithNibName:@"MainTableCell" bundle:nil] forCellReuseIdentifier:@"mainTableCell"];
Code:
NSIndexPath *path = [NSIndexPath indexPathForRow:gesture.view.tag inSection:0];
MainTableCell *cell = [self.mainTableView cellForRowAtIndexPath:path];
[self.mainTableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
And this is how the cell size is calculated
Code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
Post *post = self.posts[indexPath.row];
NSString *text = post.text;
UIFont *font = [UIFont systemFontOfSize:20];
CGRect rect = [text boundingRectWithSize:CGSizeMake(200, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName: font}
context:nil];
return (rect.size.height + 20) < 56 ? 56 : (rect.size.height + 20);
}