Skip to content

Instantly share code, notes, and snippets.

@adamgall
Created April 2, 2014 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgall/9941989 to your computer and use it in GitHub Desktop.
Save adamgall/9941989 to your computer and use it in GitHub Desktop.
// the long text that needs to fit in the label
static NSString *longText = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum aliquet ornare quam vitae pulvinar. Vestibulum dapibus posuere facilisis. Maecenas iaculis nibh eu felis accumsan, id blandit metus congue!!!";
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
NIAgendaDetailMainCell *cell = [tableView dequeueReusableCellWithIdentifier:@"agendaDetailMainCell" forIndexPath:indexPath];
cell.lblNotes.text = longText;
return cell;
} else {
// generate the other cells
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
self.mainCellTemplate.lblNotes.text = longText;
CGSize size = [self.mainCellTemplate.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
CGFloat calculatedHeight = size.height;
return calculatedHeight;
} else {
// return the static height of the other cells (44)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment