I create a custom UITableViewCell (programmatically, by subclassing) with one label and one text field.
This code
#import "TextCell.h" @implementation TextCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { UITextField *subjectField = [[UITextField alloc] initWithFrame:CGRectMake(59, 11, 399, 21)]; subjectField.font = [UIFont systemFontOfSize:17]; subjectField.placeholder = @"(placeholder)"; [self.contentView addSubview:subjectField]; self.textField = subjectField; } return self; }
leads to an invisible text field:

But if I select this cell, the text box will become visible:

If I implement
- (void)layoutSubviews { self.textField.frame = CGRectMake(59, 11, 399, 21);
the text field becomes visible, but the label goes away, and the cell width increases dramatically:

Please call me in the right direction.
source share