2.插入行
//设置编辑样式
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 1) {
return UITableViewCellEditingStyleDelete; //第二个编辑样式为删除
}
else if (indexPath.section ==2){
return UITableViewCellEditingStyleInsert; //第三个编辑样式为添加
}
return UITableViewCellEditingStyleNone;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleInsert) {
NSLog(@"%s,%d",__FUNCTION__,__LINE__);
if (2 == indexPath.row) {
//添加新生
NSMutableArray * oneGoupArray = [_allGroupArray objectAtIndex:indexPath.section];
[oneGoupArray addObject:@"云"];
//实现UI
NSIndexPath * insertIndexPath = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObjects:insertIndexPath, nil] withRowAnimation:UITableViewRowAnimationRight];
}
}
}