2

I'm creating and displaying an instance of UITableView. The delegate (which is actually my subclass of UITableView) never receives any of the following selectors:

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

even though the documentation specifically states, for example, under the discussion of 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.

Other tutorials also document this shortcut for displaying the UIMenuController in table views. Why isn't this working as documented?

4

1 回答 1

8

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

  • 表视图:shouldShowMenuForRowAtIndexPath:
  • tableView:canPerformAction:forRowAtIndexPath:withSender:
  • tableView:performAction:forRowAtIndexPath:withSender:

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

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

于 2013-04-25T13:47:19.773 回答