gpt4 book ai didi

iphone - 如何在 Obj C 的同一 View 屏幕中删除一个表中的滑动删除按钮而不是另一个表中的滑动删除按钮?

转载 作者:搜寻专家 更新时间:2023-10-30 20:03:48 24 4
gpt4 key购买 nike

在 iPhone 应用程序中,我在同一个屏幕上使用两个不同的表格 View 。现在,我想在一个 TableView 中使用滑动删除功能,但不在另一个 TableView 中使用。但是当我调用委托(delegate)方法“commiteditingstyledelete”以在两个 TableView 中获取滑动删除按钮时。如何从另一个表中删除它?我不能禁用行用户交互,因为我在 tableview 行中有一些文本字段。请提出建议。

最佳答案

在用于编辑单元格的委托(delegate)回调中,您必须检查要使用的表格,可以为每个 tableView 设置标签,或者您正在使用 ivars 检查实例,因此:

1: 用ivars

if(tableView==yourTableViewClassVar){
//your table
}

2:带标签

set the tag 
tableView.tag=10;

...然后在回调中

if(tableView.tag==10){
//your table
}

编辑:

The problem is , even when I swipe across Table2, the commiteditingstyle method is called and shows the delete button.

您还必须检查此回调中单元格的设置样式:

  - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView 
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.tag==10) {
return UITableViewCellEditingStyleNone;
}else{
return UITableViewCellEditingStyleDelete;
}
}

关于iphone - 如何在 Obj C 的同一 View 屏幕中删除一个表中的滑动删除按钮而不是另一个表中的滑动删除按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7846246/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com