我正在为我的应用程序做Bookmark模块。当我从TableView中删除行时,表中的最后一行被删除,但是从数据库中删除了所选行。问题是在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
}
}
答案 0 :(得分:1)
尝试删除代码中的以下行:
[bookmarkTableview reloadData];