我使用自定義單元格動態創建tableView。 CustomCell的.h文件看起來像這樣:自定義TableView單元格中的標籤在滾動後消失
@property (strong, nonatomic) IBOutlet UILabel *uslugaName; //I set retain doesn't work too
@property (strong, nonatomic) IBOutlet UILabel *howMuchPayLbl;
我CellForRowAtIndexPathMethod:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * cellIdentifier = @"Cell";
myCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
/*
if (!cell)
cell = [[myCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
*/
if (indexPath.row !=15) {
cell.uslugaName.text =serviceNameArr[indexPath.row];
//окрашиваем ячейку в зависимости от активности услуги
if ([uslugaIsActiveArr[indexPath.row] isEqual: @"1"]) {
cell.backgroundColor = [UIColor blackColor];
cell.howMuchPayLbl.enabled = YES;
}
else {
cell.backgroundColor = [UIColor grayColor];
cell.howMuchPayLbl.enabled = NO;
}
if (![amountTmpArr[indexPath.row] isEqual: @"0"])
cell.howMuchPayLbl.text = [NSString stringWithFormat:@"Оплачиваю: %@ KZT", amountTmpArr[indexPath.row]];
}
else {
cell.uslugaName.font = [UIFont fontWithName:@"System Bold" size:16];
cell.uslugaName.text = [NSString stringWithFormat:@"ОБЩАЯ СУММА ОПЛАТЫ: %@", fullAmount];
cell.howMuchPayLbl.hidden = YES;
}
return cell;
}
我想要的最後一行比其他人不同的(用於此目的的:
如果(indexPath.row != 15)
)。問題是 - 當滾動cell.howMuchPayLb消失。如果刪除最後一行的特殊代碼 - 一切正常,爲什麼會發生這種情況?
奇怪,但爲我工作。 – Muju