Reputation: 33
How can I create a UITableViewCell
like a UITextField
programmatically or using Interface Builder?
I tried with Interface Builder but it seems it doesn't work:
Upvotes: 0
Views: 463
Reputation: 2150
static NSString * kCellReuse = @"CellReuseIdentifier"
UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellReuse];
Upvotes: 0
Reputation: 1705
Subclass UITableViewCell and add a UITextField to the cell's contentView. You probably won't get your result without creating your own tableViewCell.
example:
MyAwesomeTextfieldCell.h
@interface MyAwesomeTextfieldCell : UITableViewCell
@property (retain, nonatomic) IBOutlet UITextField *labelTextView;
@end
MyAwesomeTextfieldCell.m
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_labelTextView = [[UITextField alloc] init];
_labelTextView.backgroundColor = [UIColor clearColor];
_labelTextView.font = [UIFont boldSystemFontOfSize:17.0];
_labelTextView.textColor = [UIColor whiteColor];
[self addSubview:_labelTextView];
}
return self;
}
Upvotes: 2