did select row at indexpath not working after context menu disappears in iOS app

781 Views Asked by At

I am implementing UIContextMenu in my App. It runs very well. Only one problem, once context menu has appeared and disappeared, tableView delegate didSelectRowAt indexPath does not work on first tap, but works on second tap. I can't seem to find what is causing this. It runs fine in Default Mail app in iPhone. Thus, I think there is something that I might be missing. Help me out. Response is appreciated.

What I have already tried is reloading tableView. Also could not find anything helpful in the docs.

@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
    }

This is the tableView delegate I implemented. Every thing works fine. All I want is that did select delegate runs on first tap after context menu disappears.

0

There are 0 best solutions below