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

  • 相关阅读:
    MongoDB入门示例及介绍
    Oracle/PLSQL CURSOR FOR Loop
    JAVA写的文件分割与文件合并程序
    synchronized 解决死锁的问题 轉貼
    采用批处理命令对文件进行解压及采用SQLCMD进行数据库挂载
    chapter6作业
    chapter5作业
    chapter4作业
    Linuz系统管理 -----账号管理
    chapter02
  • 原文地址:https://www.cnblogs.com/jackljf/p/3589241.html
Copyright © 2011-2022 走看看