gpt4 book ai didi

ios - UITableView 从不调用 tableView :shouldShowMenuForRowAtIndexPath: on its delegate

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:08:32 25 4
gpt4 key购买 nike

我正在创建并显示 UITableView 的实例。委托(delegate)(实际上是我的 UITableView 子类)从不接收以下任何选择器:

  • tableView:shouldShowMenuForRowAtIndexPath:
  • tableView:canPerformAction:forRowAtIndexPath:withSender:
  • tableView:performAction:forRowAtIndexPath:withSender:

即使 documentation具体说明,比如在tableView:shouldShowMenuForRowAtIndexPath:

的讨论下

If the user tap-holds a certain row in the table view, this method (if implemented) is invoked first. Return NO if the editing menu shouldn’t be shown—for example, the cell corresponding to the row contains content that shouldn’t be copied or pasted over.

其他教程也记录了在 TableView 中显示 UIMenuController 的快捷方式。为什么这不像记录的那样工作?

最佳答案

虽然目前没有记录(我正在提交文档更新,但谁知道何时/是否会发布),UITableViewDelegate 方法:

  • tableView:shouldShowMenuForRowAtIndexPath:
  • tableView:canPerformAction:forRowAtIndexPath:withSender:
  • tableView:performAction:forRowAtIndexPath:withSender:

仅当您的 TableView 实例由 UITableViewController 实例管理时才会调用。独立 TableView 不会调用这些方法。

如果您的 TableView 未连接到 TableView Controller ,则您需要在每个 TableView 单元格上从长按监听器(以复制标准系统功能)手动显示 UIMenuController。

关于ios - UITableView 从不调用 tableView :shouldShowMenuForRowAtIndexPath: on its delegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16216503/

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