简体   繁体   English

UITableView永远不会在其委托上调用tableView:shouldShowMenuForRowAtIndexPath:

[英]UITableView never calls tableView:shouldShowMenuForRowAtIndexPath: on its delegate

I'm creating and displaying an instance of UITableView . 我正在创建并显示UITableView的实例。 The delegate (which is actually my subclass of UITableView ) never receives any of the following selectors: 委托(实际上是UITableView子类)从未收到以下任何选择器:

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

even though the documentation specifically states, for example, under the discussion of tableView:shouldShowMenuForRowAtIndexPath: 即使该文档明确指出,例如在tableView:shouldShowMenuForRowAtIndexPath:的讨论中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. 如果不应显示编辑菜单,则返回NO-例如,与该行相对应的单元格包含不应复制或粘贴的内容。

Other tutorials also document this shortcut for displaying the UIMenuController in table views. 其他教程也记录了此快捷方式,用于在表视图中显示UIMenuController Why isn't this working as documented? 为什么这不符合记录?

Although it isn't currently documented (I'm submitting a documentation update, but who knows when/if it will be posted), the UITableViewDelegate methods: 尽管目前尚未记录(我正在提交文档更新,但谁知道何时/是否将其发布),UITableViewDelegate方法:

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

are only called if your table view instance is managed by an instance of UITableViewController. 仅在您的表视图实例由UITableViewController实例管理时才调用。 A standalone table view will not have these methods invoked. 独立表视图将不会调用这些方法。

If your table view isn't connected to a table view controller, then you'll need to display the UIMenuController manually from long tap listeners (to duplicate the standard system functionality) on each table view cell. 如果表视图未连接到表视图控制器,则需要在每个表视图单元格上从长抽头侦听器(以复制标准系统功能)手动显示UIMenuController。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM