zoukankan      html  css  js  c++  java
  • 二维数组左滑删除某一行

    #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];
        }
    }

    实现二维数组的删除某一行

  • 相关阅读:
    马哥Linux——第三周作业
    [laravel]phpunit
    [laravel]要点
    [laravel]请求处理
    [angularJS]ng-hide|ng-show切换
    [yii2]urlmanger
    虚拟机bridged, NAT and host-only网络区别
    [yii]Fetch data from database and create listbox in yii
    [shell test] multiple conditions
    特殊的shell变量:
  • 原文地址:https://www.cnblogs.com/ritian/p/5495635.html
Copyright © 2011-2022 走看看