我可以为特定行停止 contextMenuConfigurationForRowAt 吗?

时间:2021-05-06 09:46:50

标签: ios swift

我在我的 tableview 上使用了 contextMenuConfigurationForRowAt,但我想根据数据启用/禁用它

是否有可能对所有单元格都执行?

谢谢

1 个答案:

答案 0 :(得分:1)

检查Docs

<块引用>

使用此方法提供描述要呈现的菜单的 UIContextMenuConfiguration。返回 nil 以防止交互开始。

func tableView(_ tableView: UITableView, 
     contextMenuConfigurationForRowAt indexPath: IndexPath, 
              point: CGPoint) -> UIContextMenuConfiguration? {
      return arr[indexPath.row].showMenu ? menu : nil
 }