dal*_*ijn 2 iphone objective-c uitableview ios
我有动态tableView与自定义单元格.CustomCell .h文件如下所示:
@property (strong, nonatomic) IBOutlet UILabel *uslugaName; //I set retain doesn't work too
@property (strong, nonatomic) IBOutlet UILabel *howMuchPayLbl;
Run Code Online (Sandbox Code Playgroud)
我的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;
}
Run Code Online (Sandbox Code Playgroud)
我希望最后一行与其他行不同(为此目的:
if(indexPath.row!= 15)
).问题是 - 当滚动cell.howMuchPayLb消失.如果删除最后一行的特殊代码 - 一切正常,为什么会发生这种情况?
您的代码有一个if else语句,其中一个分支可以设置,cell.howMuchPayLbl.hidden = YES;但另一个分支没有设置cell.howMuchPayLbl.hidden = NO;.因此,一旦标签被隐藏,它将永远不会被隐藏.当重复使用具有隐藏标签的单元格时,标签将保持隐藏状态.
cell.howMuchPayLbl.hidden = NO;在if语句中添加(以及任何其他"反向"配置).
| 归档时间: |
|
| 查看次数: |
2262 次 |
| 最近记录: |