0
UICTableView의 선택된 항목을 겹쳐 쓰기 확인란의 NSMutableDictionary에 저장해야합니다. 그래서 나는 다음과 같이한다.UITableView 선택한 항목 저장
NSMutableDictionary * selDict;// - instance variable
...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([selDict objectForKey:indexPath])
[selDict setObject:[NSNumber numberWithBool:FALSE] forKey:indexPath];
else
[selDict setObject:[NSNumber numberWithBool:TRUE] forKey:indexPath];
[[self tableView]reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
if ([selDict objectForKey:indexPath])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
...
return cell;
}
그러나 체크 된 항목 만 설정하고 더 이상 작동하지 않는다.
더 이상 작동하지 않는다는 것은 무엇을 의미합니까? 또한 [[[self tableView] reloadData] 대신에 [[self tableView] reloadRowsAtIndexPaths : [NSArray arrayWithObject : indexPath] withRowAnimation : UITableViewRowAnimationNone]'을 사용하는 것이 더 좋다. (전체 테이블을 다시 읽어들이는 지점이 없다) –
팁 주셔서 감사. 그것은 또한 나를 위해 작동합니다. –