我确实检查了didSelectRow
方法,但是当我向上移动表格时,它删除了我认为它创建新单元格的检查
如何使用唯一单元格,以便它不会将选中的单元格替换为未选中的单元格。
- (void)tableAlert:(SBTableAlert *)tableAlert didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"MY INDEX PATH IS %@", indexPath);
NSString *email = [allEmails objectAtIndex:indexPath.row];
if (tableAlert.type == SBTableAlertTypeMultipleSelct) {
UITableViewCell *cell = [tableAlert.tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone){
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
[selectedEmail addObject:email];
}
else{
[cell setAccessoryType:UITableViewCellAccessoryNone];
[selectedEmail removeObject:email];
}
[tableAlert.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
NSLog(@"Final Array is %@", selectedEmail);
}
- (UITableViewCell *)tableAlert:(SBTableAlert *)tableAlert cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
// NSString *identifier = [NSString stringWithFormat:@"%d%d", indexPath.section, indexPath.row];
if (tableAlert.view.tag == 0 || tableAlert.view.tag == 1) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
} else {
// Note: SBTableAlertCell
cell = [[SBTableAlertCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
}
//[cell.textLabel setText:[NSString stringWithFormat:@"Cell %d", indexPath.section]];
NSString *email = [allEmails objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%@", email];
UIFont *myFont = [ UIFont fontWithName: @"Arial" size: 14.0 ];
cell.textLabel.font = myFont;
return cell;
}