objective c在表视图中滑动以删除

时间:2017-01-23 16:37:12

标签: objective-c swipe

我有两个自定义单元格。我试图滑动删除按钮。 但是当我点击删除按钮时崩溃了。

以下是代码:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        if (indexPath.row % 2 == 0) {
            [_arrayCars removeObjectAtIndex:indexPath.row/2];
            [_tblCars deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        }else{
            [_arrayGirls removeObjectAtIndex:(indexPath.row - 1)/2];
            [_tblCars deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
        }
        withRowAnimation:UITableViewRowAnimationFade];
    } else {
        NSLog(@"Unhandled editing style! %d", editingStyle);
    }
}

这是我得到的:

    ExampleXib[6957:281486] -[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance 0x7feea851bc60
    2017-01-23 19:31:49.798 ExampleXib[6957:281486] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance 0x7feea851bc60'

0 个答案:

没有答案