문제

After deleting a row, it is still showed.

-(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
        });
    }];
}

this method calls that function:

-(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];
    });
}

I don't understand when I should call reloadData to update view.

도움이 되었습니까?

해결책 2

When you delete a row of table view also remove the related record from array, then after reload tableview.

다른 팁

Can't see the delete method in your code. This is how you have to use the delete row methods.

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

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

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top