如何以編程方式或使用Interface Builder創建UITableViewCell
,如UITextField
?如何創建一個像UITextField一樣的UITableViewCell?
我試圖與界面生成器,但它似乎它不工作:
如何以編程方式或使用Interface Builder創建UITableViewCell
,如UITextField
?如何創建一個像UITextField一樣的UITableViewCell?
我試圖與界面生成器,但它似乎它不工作:
子類的UITableViewCell併爲UITextField添加到單元格的內容查看。如果不創建自己的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];
抱歉,我會說我如何創造的UITextField像一個UITableViewCell編程或使用Interface Builder ? – User
看看我的例子。這是以編程方式執行的一種方式。當然你也可以使用Interface Builder來完成。只需在您的自定義課程中添加一個筆尖即可。 –