zoukankan      html  css  js  c++  java
  • tableview侧滑删除

    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (indexPath.section == 0) {
            return NO;
        }
        return YES;
    }
    
    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewCellEditingStyleDelete;
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return @"删除";
    }
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            NSInteger index = (indexPath.section-1);
            Address *address = [self.addressArray objectAtIndex:index];
            
            //联网删除地址
            [SVProgressHUD showWithStatus:@"正在删除.."];
            NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:address.AddressID, @"AddressID", nil];
            [self.afServiceHelper getDefaultJsonWithSubMethod:@"AddressInfo_AddressID_Delete" parameters:dict cachePolicy:NSURLRequestUseProtocolCachePolicy success:^(id json) {
                [SVProgressHUD dismiss];
                NSDictionary *resultDict = json;
                if ([[resultDict objectForKey:M_Code] integerValue] == 0) {
                    [self.addressArray removeObjectAtIndex:index];
                    NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:indexPath.section];
                    [tableView deleteSections:indexSet withRowAnimation:UITableViewRowAnimationLeft];
                } else {
                    [self.tableView makeToast:[resultDict objectForKey:M_Msg] duration:1.0 position:@"center"];
                }
                
            } failure:^(NSError *error, NSString *msg) {
                if(error.code == NSURLErrorNotConnectedToInternet) {
                    [SVProgressHUD dismiss];
                    [self.tableView makeToast:@"没有网络" duration:1.0 position:@"center"];
                } else {
                    [SVProgressHUD dismissWithError:@"删除失败"];
                }
            }];
            
        }
    }
  • 相关阅读:
    向量期望与方差的关系
    向量范数的柯西不等式
    pandas sample函数
    latex 插入表格的网址
    寻找原根
    反射
    python库下载速度慢的解决
    anaconda3 修改python版本
    spark RDD的缓存和检查点不同使用场景和工作机制 -- (视频笔记)
    HTML一键打包APK解决误报毒问题
  • 原文地址:https://www.cnblogs.com/apem/p/4580823.html
Copyright © 2011-2022 走看看