[英]How can I create a UITableViewCell like a UITextField?
How can I create a UITableViewCell
like a UITextField
programmatically or using Interface Builder? 如何以编程方式或使用Interface Builder创建
UITableViewCell
如UITextField
?
I tried with Interface Builder but it seems it doesn't work: 我尝试使用Interface Builder但它似乎不起作用:
Subclass UITableViewCell and add a UITextField to the cell's contentView. 子类UITableViewCell并将UITextField添加到单元格的contentView。 You probably won't get your result without creating your own tableViewCell.
如果不创建自己的tableViewCell,您可能无法获得结果。
example: 例:
MyAwesomeTextfieldCell.h MyAwesomeTextfieldCell.h
@interface MyAwesomeTextfieldCell : UITableViewCell
@property (retain, nonatomic) IBOutlet UITextField *labelTextView;
@end
MyAwesomeTextfieldCell.m 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;
}
static NSString * kCellReuse = @"CellReuseIdentifier"
UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellReuse];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.