0

How to make a non clickable menu Item in UIContextMenuConfiguration? At the moment, when I click on the menu item, nothing happens and the menu just closes. I need the menu not to close when I click on the item.

Here is some code:

@available(iOS 13.0, *)
var contextMenuConfiguration: UIContextMenuConfiguration {
    let configuration = UIContextMenuConfiguration(
        identifier: nil,
        previewProvider: nil
    ) { [weak self] _ -> UIMenu? in
        guard let strongSelf = self else { return nil }

        var actions: [UIAction] = []
        actions.append(
            UIAction(title: "\(l10n(.id)) \(strongSelf.connection.id)",
                     image: UIImage(systemName: "info.circle")) { _ in
            strongSelf.delegate?.idPressed()
        })

And here code of my func:

func idPressed() {
    <#code#>
}
Morozov
  • 4,968
  • 6
  • 39
  • 70

1 Answers1

1

Solved this problem with next solution:

    actions.append(
        UIAction(
            title: "\(l10n(.id)) \(strongSelf.connection.id)",
            image: UIImage(systemName: "info.circle"),
            attributes: .disabled) { _ in
            return
        }
    )
Morozov
  • 4,968
  • 6
  • 39
  • 70