我使用下面的代码来填充tableview行。在单击一行时,我正在重新加载表数据,但行未被更新。 iOS的11之前,它工作正常,但在更新到iOS 11后我面对这个问题:UITableview单元格在reloaddata上不更新
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DayCell" forIndexPath:indexPath];
UILabel *label = [cell viewWithTag:101];
UIImageView *imageView = [cell viewWithTag:102];
NSArray *days = @[@"Sunday", @"Monday", @"Tuesday", @"Wednesday", @"Thursday", @"Friday", @"Saturday"];
label.text = [days objectAtIndex:indexPath.row];
if ([_selectedDays containsObject:label.text]) {
imageView.image = [UIImage imageNamed:@"CheckedIcon"];
} else {
imageView.image = nil;
}
return cell;
}
,我在didSelectRowAtIndexPath方法是这样重装数据:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
UILabel *label = [cell viewWithTag:101];
if ([_selectedDays containsObject:label.text]) {
[_selectedDays removeObject:label.text];
} else {
[_selectedDays addObject:label.text];
}
[tableView reloadData];
}
难道我做错了什么?
如何将宣布'_selectedDays' –
我初始化'_selectedDays'在'viewDidLoad'为'_selectedDays = [NSMutableArray的新]' –
你把对象追加到'_selectedDays' –