标签:
#pragma mark 编辑操作(删除或添加) //实现了此方法向左滑动就会显示删除(或添加)图标 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ NTContactGroup * group = _contacts[indexPath.section]; NTContact * contact = group.contacts[indexPath.row]; if (editingStyle == UITableViewCellEditingStyleDelete) { [group.contacts removeObject:contact]; [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationBottom]; if (group.contacts.count == 0) { [_contacts removeObject:group]; [tableView reloadData]; } }else if (editingStyle == UITableViewCellEditingStyleInsert){ NTContact * addContact = [[NTContact alloc]init]; addContact.firstName = @"Guan"; addContact.lastName = @"yu"; addContact.mobileNumber = @"12345678901"; [group.contacts insertObject:addContact atIndex:indexPath.row]; [tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationBottom]; } }
实现二维数组的删除某一行
标签:
原文地址:http://www.cnblogs.com/ritian/p/5495635.html