![](/img/trans.png)
[英]How can I get reference to UITextField from UITableViewCell?
[英]How can I create a UITableViewCell like a UITextField?
如何以編程方式或使用Interface Builder創建UITableViewCell
如UITextField
?
我嘗試使用Interface Builder但它似乎不起作用:
子類UITableViewCell並將UITextField添加到單元格的contentView。 如果不創建自己的tableViewCell,您可能無法獲得結果。
例:
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;
}
static NSString * kCellReuse = @"CellReuseIdentifier"
UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellReuse];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.