所以我试图删除表视图中的行。
这是我的代码:
- (IBAction)done:(UIStoryboardSegue *)segue
{
DetailGodsViewController *detailController = [segue sourceViewController];
NSIndexPath *path = [NSIndexPath indexPathForRow:detailController.row inSection:detailController.section];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:path]
withRowAnimation:NO];
[self.listOfGoods deleteGood: detailController.row];
[[self tableView] reloadData];
[self dismissViewControllerAnimated:YES completion:NULL];
}
我在storyBoard中有ControlViewTable,单击ControlViewTable中的一行后,它会跳转到详细信息视图还有其他信息,我也在此函数中存储有关行和部分的信息:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowGoodDetails"]) {
DetailGodsViewController *detailViewController = [segue destinationViewController];
detailViewController.row = [self.tableView indexPathForSelectedRow].row;
detailViewController.section = [self.tableView indexPathForSelectedRow].section;
detailViewController.good = [self.listOfGoods getGoodAtIndex:detailViewController.row ];
}
在详细视图中还有一个按钮用于删除,点击后跳转到功能:
- (IBAction)done:(UIStoryboardSegue *)segue.
但它总是在 deleteRows 中崩溃。有人可以帮忙吗?