Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何实施";轻扫以删除";UITableView中的自定义UITableViewCell不在UITableViewController中?_Uitableview - Fatal编程技术网

如何实施";轻扫以删除";UITableView中的自定义UITableViewCell不在UITableViewController中?

如何实施";轻扫以删除";UITableView中的自定义UITableViewCell不在UITableViewController中?,uitableview,Uitableview,有人能提供源代码吗? 我设置了数据源和委托,并尝试了 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAt

有人能提供源代码吗? 我设置了数据源和委托,并尝试了

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //remove the deleted object from your data source.
    }
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;
}
但它不起作用。 如果可能的话,我不想将UIgestureRecognitor添加到单元格中

如果有人提出建议,我将不胜感激


多谢各位

确保.h文件中的控制器正在实现UITableViewDelegate协议,并将表数据源设置为该控制器。试试这个,如果调用了这些函数,请告诉我

例如

SomeController.h文件

@interface SomeController : UIViewController <UITableViewDataSource>
....

-祝你好运

什么东西不管用?是否调用了任何委托方法?按钮是否出现但未执行任何操作?“滑动以删除”自定义UITableViewCell不工作。我的手机位于UITableView中,而UITableViewController中没有。如果我滚动表格,会调用tableView:caneditrowatinexpath:method;如果我在单元格上滑动,则不会调用任何方法。“删除”按钮从未出现。嗨,科雷,我已经设置好了一切,它不工作了。但我发现了一些新的东西:如果我创建了一个新项目,并将带有UITableView的视图控制器放入其中,“滑动以删除”起作用。我还尝试将视图控制器放入UINavigationController,并将UINavigationController作为根视图控制器,它也起作用了。所以我猜视图控制器的容器有问题。在我的实际项目中,我的视图控制器位于UINavigationController中,而我的UINavigationController位于我编写的BaseViewController中。你知道我应该如何使用BaseViewController吗?非常感谢!嘿,太棒了,很高兴听到你的问题解决了,希望我能帮上忙。至于你的BaseViewController,如果不看代码,我不确定到底发生了什么=/嘿,我明白了!因为我的BaseViewController是一个SidePanelViewController,它的功能类似于facebook iOS应用程序的侧面板。侧面板控制器和UITableView之间存在滑动手势冲突。非常感谢你,科雷!
....

    myTableView.dataSource = self;

....