【问题标题】:Selected row is not deleting from UITableView所选行未从 UITableView 中删除
【发布时间】:2012-11-30 06:17:21
【问题描述】:

我正在为我的应用程序做书签模块。当我从 TableView 中删除行时,表中的最后一行被删除,但从数据库中选定的行被删除。问题是在表格视图中显示数据时

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

    [[UIBarButtonItem appearanceWhenContainedIn:[UIPopoverController class], nil]
     setTintColor:[UIColor grayColor]];
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        Cart *cartObj = [appDelegate.bookmarkArray objectAtIndex:indexPath.row];
        [appDelegate removeCart:cartObj];
        [bookmarkIDArray removeObjectAtIndex:indexPath.row];
       [bookmarkTableview beginUpdates];

        [bookmarkTableview deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
        //[bookmarkTableview deleteSections:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
        [bookmarkTableview endUpdates];
        [bookmarkTableview reloadData];
    }
    if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}

【问题讨论】:

    标签: objective-c uitableview bookmarks delete-row


    【解决方案1】:

    尝试删除代码中的以下行:

    [bookmarkTableview reloadData];
    

    【讨论】: