以下のコードを使用して、テーブルビューの行を設定しています。行をクリックすると、テーブルのデータがリロードされていますが、行は更新されていません。 iOSの11の前にそれが正常に働いていたが、iOSの11に更新した後、私はこの問題に直面しています:UITableviewセルがリロードデータで更新されない
-(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];
}
私が何か間違ったことをやっていますか? didSelectRowAtIndexPath
方法で
はどのようにあなたが '_selectedDays' –
私としてviewDidLoad''で '_selectedDays'を初期化しています宣言します' _selectedDays = [NSMutableArrayの新しいです]; ' –
オブジェクトを '_selectedDays'に追加します –