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就行了

  • 相关阅读:
    最长公共子序列
    学习MySQL常用操作命令
    using的几种用法
    C++循环的简单使用【闲来写来练练手~】
    使用【数据库收缩功能】实现多个数据文件的合并
    Google的十个核心技术(摘自CSDN)
    OPENGL入门学习
    dive into python 第 5 章 对象和面向对象
    [转]已知两圆圆心坐标及半径求两圆交点 (C语言|参数方程求解)
    The Python Tutorial 4. More Control Flow Tools的一些小记
  • 原文地址:https://www.cnblogs.com/jackljf/p/3589241.html
Copyright © 2011-2022 走看看