Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try it without NSAttributedString...this works for me: </p> <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; { NSManagedObject *obj = [results objectAtIndex:indexPath.row]; NSString *text = [obj valueForKey:@"name"]; NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:FONT_SIZE], NSFontAttributeName, nil]; CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f); CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size; CGFloat height = MAX(size.height, 45.0f); return height ; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; TVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[TVCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } NSManagedObject *obj = [results objectAtIndex:indexPath.row]; NSString *text = [obj valueForKey:@"name"]; NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:FONT_SIZE], NSFontAttributeName, nil]; CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f); CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size; [cell.cellText setText:text]; [cell.cellText setFrame:CGRectMake(CELL_CONTENT_MARGIN, 0.0, CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), MAX(size.height, 45.0f))]; return cell; } </code></pre> <p>In TVCell.m: </p> <pre><code> self.cellText = [[UILabel alloc] initWithFrame:CGRectZero]; [self.cellText setLineBreakMode:NSLineBreakByWordWrapping]; [self.cellText setMinimumScaleFactor:FONT_SIZE]; [self.cellText setNumberOfLines:0]; [self.cellText setFont:[UIFont systemFontOfSize:FONT_SIZE]]; self.cellText.textColor = [UIColor colorWithRed:64/255.0 green:59/255.0 blue:59/255.0 alpha:1.0]; [self.contentView addSubview:self.cellText]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload