I’m having a problem with my iOS app and getting a UILabel in a UITableViewCell to wrap. The text shows but it will only display on one line.
Here is my code:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
UILabel *noteLabel = (UILabel *)[cell.contentView viewWithTag:2];
NSDictionary *contact = [jsonResults objectAtIndex:indexPath.row];
noteLabel.lineBreakMode = UILineBreakModeWordWrap;
noteLabel.numberOfLines = 0;
noteLabel.text = [contact objectForKey:@"note"];
return cell;
}
I believe the problem has something to do with this line:
UILabel *noteLabel = (UILabel *)[cell.contentView viewWithTag:2];
I’m not sure how else to get the label from a tag and I think this line won’t let me change the labels properties.
You may need to set the label’s height: