Skip to content

Instantly share code, notes, and snippets.

@warriorg
Created December 10, 2015 05:37
Show Gist options
  • Save warriorg/202a8b03a84598e24b9f to your computer and use it in GitHub Desktop.
Save warriorg/202a8b03a84598e24b9f to your computer and use it in GitHub Desktop.
UITableView row height dynamic
static UITableViewCell *sizingCell = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sizingCell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
});
[sizingCell setNeedsLayout];
[sizingCell layoutIfNeeded];
CGFloat height = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return height;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment