iOS UItableView 슬라이드업 제거

2043 단어
  • 주의: 데이터를 먼저 삭제한 다음에 삭제된 애니메이션이나 다른 조작을 실행해야 한다. 그렇지 않으면 충돌이 발생할 수 있다
  • #pragma mark ----     
    //    “     Delete  ”       
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [self queyDeletePath:indexPath];
    
    }
    
    //      
    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        return UITableViewCellEditingStyleDelete;
    }
    
    //   Delete     “  ”
    - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return @"  ";
    }
    
    //   Cell   
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
        if (self.selectType == CarListTypeEidite) {
            return YES;
        }else{
           return NO;
        }
    }
    
    //         ,Cell     
    - (BOOL)tableView: (UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
          return NO;
    }
    
    
    #pragma mark ---          
    - (void)queyDeletePath:(NSIndexPath *)indexPath{
        
        
        NSMutableDictionary *param = [NSMutableDictionary dictionary];
        [param SetNoNilObject:[self.dataArr[indexPath.row] cid] forKey:@"carid"];
        [param SetNoNilObject:[User shareUser].mid forKey:@"id"];
        
        wselfCode
        [NetWorkTools POST:deleteCarPath parameters:param success:^(NSDictionary *responseObject, BOOL isSuccess) {
            if ([responseObject GetStringForKey:@"code"].integerValue == 1) {
                
                //     
                [wself.dataArr removeObjectAtIndex:indexPath.row];
                
                //   
                [wself.mainTableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
                
            }else{
                
                [MBProgressHUD showMessage:[responseObject GetStringForKey:@"msg"]];
            }
            
        } failure:^(NSError *error) {
            
        }];
        
    }
    
    

    좋은 웹페이지 즐겨찾기