【问题标题】:How to make a non clickable menu Item in UIMenu?如何在 UIMenu 中制作不可点击的菜单项?
【发布时间】:2021-10-05 03:02:47
【问题描述】:

如何在 UIContextMenuConfiguration 中制作不可点击的菜单项? 目前,当我单击菜单项时,什么也没有发生,菜单就关闭了。 当我单击该项目时,我需要菜单不要关闭。

这里有一些代码:

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

这里是我的函数代码:

func idPressed() {
    <#code#>
}

【问题讨论】:

    标签: ios swift uimenu


    【解决方案1】:

    用下一个解决方案解决了这个问题:

        actions.append(
            UIAction(
                title: "\(l10n(.id)) \(strongSelf.connection.id)",
                image: UIImage(systemName: "info.circle"),
                attributes: .disabled) { _ in
                return
            }
        )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-26
      相关资源
      最近更新 更多