1

我正在UIContextMenu我的应用程序中实施。它运行得很好。只有一个问题,一旦上下文菜单出现和消失,tableView代理didSelectRowAtindexPath 在第一次点击时不起作用,但在第二次点击时起作用。我似乎无法找到造成这种情况的原因。它在 iPhone 的默认邮件应用程序中运行良好。因此,我认为我可能会遗漏一些东西。帮帮我。回应表示赞赏。

我已经尝试过的是重新加载tableView。在文档中也找不到任何有用的东西。

@available(iOS 13.0, *)
    func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
        if indexPath.section == 0 {
            let contextMenuConfiguration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { (menuElements) -> UIMenu? in
                let edit = UIAction(title: "Edit", image: UIImage.placeholderIcon) { (action) in
                    print("Edit")
                    self.editInvoice(at: indexPath)
                }
                let preview = UIAction(title: "Preview", image: UIImage.placeholderIcon) { (action) in
                    print("Preview")
                }
                let send = UIAction(title: "Send", image: UIImage.placeholderIcon) { (action) in
                    print("Send")
                }
                let share = UIAction(title: "Share", image: UIImage.placeholderIcon) { (action) in
                    print("Share")
                }
                return UIMenu(title: "", image: UIImage.invoiceIcon, identifier: nil, options: UIMenu.Options.displayInline, children: [edit, preview, send])
            }
            return contextMenuConfiguration
        }
        return nil
    }

这是tableView我实现的委托。每件事都很好。我想要的只是在上下文菜单消失后第一次点击时选择委托运行。

4

0 回答 0