Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a UILabel to UiTableViewCell - text is being cropped vertically
    primarykey
    data
    text
    <p>Running into a problem when I try and add a UILabel to a custom UITableViewCell. For some reason the frame's are not being respected at all - when I try and set the label height (through CGRectMake) the text is being cropped vertically. In other words, only half of the text is being shown.</p> <p>When I play around with the CGRectMake's frame height it shows some strange behavior - sometimes a lower value will actually make things align properly.</p> <p>Am I setting the wrong values? Is the frame the wrong property to be modifying?</p> <p>Edit for code:</p> <pre><code>- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { // Initialization code eventName = [[UILabel alloc] initWithFrame:CGRectZero]; //eventName.backgroundColor = [UIColor blueColor]; eventName.numberOfLines = 2; eventName.minimumFontSize = 8.; eventName.adjustsFontSizeToFitWidth = YES; eventName.text = @"Event Name"; [self.contentView addSubview:eventName]; eventStartEndDate = [[UILabel alloc] initWithFrame:CGRectZero]; eventStartEndDate.backgroundColor = [UIColor blueColor]; eventStartEndDate.text = @"Event Start and End Dates"; [self.contentView addSubview:eventStartEndDate]; description = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 30.0, 300.0, 20.0)]; [self.contentView addSubview:description]; } return self; } -(void)layoutSubviews { [super layoutSubviews]; if (!self.editing) { eventName.frame = CGRectMake(10.0, 10.0, 300.0, 20.0); eventStartEndDate.frame = CGRectMake(10.0, 35.0, 300.0, 20.0);; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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