1

I am trying to create a table with unique styling so that my label size dynamically changes with the content. I was able to get the cell to change style after it has been dequeued once (ie once I scroll down to a new page, those cells are formatted and then when I scroll back up the cells are formatted) but cannot seem to do this one the initial load. The labels are scoped only to that method because anytime I tried to make them more available, it caused the storyboard to fail.

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];


NSDictionary *pastVerse = [self.pastVerses objectAtIndex:indexPath.row];

UILabel *label;

label = (UILabel *)[cell viewWithTag:1];
label.text = [pastVerse valueForKey:@"reference"];

label = (UILabel *)[cell viewWithTag:2];
label.text = [pastVerse valueForKey:@"version"];

label = (UILabel *)[cell viewWithTag:3];
label.text = [pastVerse valueForKey:@"verse"];

[label setNumberOfLines:0];
[label sizeToFit];
emk411
  • 177
  • 8
  • You're going to need to post some code. – paulrehkugler Nov 14 '13 at 17:17
  • http://stackoverflow.com/questions/11981071/dynamic-height-for-static-table-cells-with-wrapping-labels – Shubhank Nov 14 '13 at 19:01
  • I can't do this because it's not the cell height that's not working but the UIlabel size in conjunction with the cell height. I can solve the cell height problem once the labels size properly on the initial load. – emk411 Nov 14 '13 at 20:15

0 Answers0