2014-05-12 25 views
0

删除一行后,仍然显示。从UITableView中删除一行后,仍然显示为

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    Audio *current = [logic findAudioByRow:indexPath.row]; 
    [logic deleteAudio:current callback:^{ 
     dispatch_async(dispatch_get_main_queue(), ^{ 
      //some audio player logic that does not important for the topic 
     }); 
    }]; 
} 

此方法调用该函数:

-(void)deleteAudio:(Audio *)audio callback:(voidCallback)callback 
{ 
    dispatch_async(dispatch_get_global_queue(0, 0), ^{ 
     NSString * ownerId = [NSString stringWithFormat:@"%ld", [audio.owner_id integerValue]]; 
     NSString * audioId = [NSString stringWithFormat:@"%ld", [audio.aid integerValue]]; 

     APIData *apiData = [[APIData alloc] initWithMethod:DELETE_AUDIO_BY_ID user:[[UserLogic instance] currentUser] queue:requestQueue params:[[NSMutableDictionary alloc] initWithObjectsAndKeys:audioId,@"aid", ownerId, @"oid", nil]]; 

     [APIRequest executeRequestWithData:apiData block:^(NSURLResponse *response, NSData *data, NSError *error) { 
     }]; 
     callback(); 
     [self updateContent:YES]; 
    }); 
} 

我不明白的时候我应该打电话reloadData更新视图。

+0

你在哪里删除tableview我的朋友的行。? –

+0

使用[tableview reloadData] – Mohit

回答

1

当你删除一行表视图的同时也从数组中删除相关的记录,然后重新加载tableview后。

4

无法在您的代码中看到删除方法。这就是你如何使用删除行方法。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 

     [mySourceArray removeObjectAtIndex:indexPath.row]; 
     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 

} 
相关问题