[英]configureCell method does not work in a Custom cell
我已經實現了帶有一些自定義單元格的UITableView,用於驗證UITextField和日期選擇器。 我想做一個簡單的任務,但我不明白為什么它不起作用。 我只想更改UILabel文本屬性。 我有這段代碼來調用cellForRowAtIndex中的單元格...
birthDateCell = (WPBirthDatePickerCell *)[aTableView dequeueReusableCellWithIdentifier:BirthDateCellIdentifier];
if(birthDateCell == nil){
// INIT REUSABLE CELL
birthDateCell = [[WPBirthDatePickerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BirthDateCellIdentifier] ;
[birthDateCell setAccessoryType:UITableViewCellAccessoryNone];
// countryCell. = self;
}
if (indexPath.row == 5 ){
[birthDateCell configureCellWithString:fechaNacimiento];
return birthDateCell;
}
還有我的自定義單元
@implementation WPBirthDatePickerCell
@synthesize birthDateLbl, validateLbl;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
validateLbl = [[WPCustomLabel alloc] initWithFrame:CGRectMake(20, 10, 80, 30)];
validateLbl.textColor = [UIColor blackColor];
validateLbl.font = [UIFont systemFontOfSize:14.0];
validateLbl.text = @"Birth Day ";
[validateLbl setTextAlignment:NSTextAlignmentLeft];
[self addSubview:validateLbl];
birthDateLbl = [[WPCustomLabel alloc] initWithFrame:CGRectMake(110, 10, 200, 30)];
birthDateLbl.textColor = [UIColor blackColor];
birthDateLbl.font = [UIFont systemFontOfSize:14.0];
[birthDateLbl setTextAlignment:NSTextAlignmentLeft];
[self addSubview:birthDateLbl];
[self configureCellWithString:@"Whate ever"];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}
-(void) configureCellWithString:(NSString *)birthDate
{
birthDateLbl.text = birthDate;
NSLog(@"%@", birthDateLbl.text);
}
當用戶在datePicker
選擇正確的日期時,我調用configureCellWithString
方法
這很奇怪,因為我使它的UIlabel文本屬性成為NSLog,它在輸出中顯示了正確的文本,但在實際Cell中卻沒有顯示。 任何想法 ? 謝謝,這是可重用性的問題嗎?
我想對此發表評論,但我還不能發表評論。 確保更改單元格信息后重新加載表數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.