2011-10-23 58 views

回答

2

子類的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; 
} 
+0

抱歉,我會說我如何創造的UITextField像一個UITableViewCell編程或使用Interface Builder ? – User

+0

看看我的例子。這是以編程方式執行的一種方式。當然你也可以使用Interface Builder來完成。只需在您的自定義課程中添加一個筆尖即可。 –

0
static NSString * kCellReuse = @"CellReuseIdentifier" 
UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellReuse]; 
相關問題