zoukankan      html  css  js  c++  java
  • UITableView 删除表格单元写法

    - (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
                forRowAtIndexPath:(NSIndexPath *)indexPath {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            NSDictionary *section = [data objectAtIndex:indexPath.section];
            if (section) {
                NSMutableArray *content = [section valueForKey:@"content"];
                if (content && indexPath.row < [content count]) {
                    [content removeObjectAtIndex:indexPath.row];
                }
            }
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
        }
     else if (editingStyle == UITableViewCellEditingStyleInsert) {
            NSDictionary *section = [data objectAtIndex:indexPath.section];
            if (section) {
                // Make a local reference to the editing view controller.
                EditingViewController *controller = self.editingViewController;
                NSMutableArray *content = [section valueForKey:@"content"];
                // A "nil" editingItem indicates the editor should create a new item.
                controller.editingItem = nil;
                // The group to which the new item should be added.
                controller.editingContent = content;
                controller.sectionName = [section valueForKey:@"name"];
                controller.editingTypes = [section valueForKey:@"types"];
                [self.navigationController pushViewController:controller animated:YES];
            }
        }
    }

    //那一行是要自己添加的 然后把新加那一行的属性设置成UITableViewCellEditingStyleInsert就行了

  • 相关阅读:
    数据结构笔记(第三章)
    数据结构笔记(第二章)
    Java第三阶段学习(四、缓冲流)
    Java第三阶段学习(三、字符流、转换流)
    Java第三阶段学习(二、IO流--------递归,字节流Stream)
    Java学习(异常类)
    Java学习(异常类练习题)
    Java学习(JDBC java连接数据库)
    Java学习(Map接口)
    Java学习(set接口、HashSet集合)
  • 原文地址:https://www.cnblogs.com/jackljf/p/3589241.html
Copyright © 2011-2022 走看看