質問

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