【问题标题】:UIButton and Temporary UIMenuUIButton 和临时 UIMenu
【发布时间】:2021-06-11 16:09:55
【问题描述】:

你能根据外部条件改变 UIButton 是否有 UIMenu 吗?

let infoButton = UIButton()
infoButton.showsMenuAsPrimaryAction = true
infoButton.menu = UIMenu(options: .displayInline, children: [])
infoButton.addAction(UIAction { [weak infoButton] (action) in
   infoButton?.menu = infoButton?.menu?.replacingChildren([new items go here...])
}, for: .menuActionTriggered)

有没有办法阻止该菜单,但在某些条件下触发 TouchUpInside 类型的控件事件?

【问题讨论】:

    标签: ios swift uibutton uimenucontroller uimenu


    【解决方案1】:

    如果您不希望在点击按钮时出现菜单,则不应将 showsMenuAsPrimaryAction 设置为 true。该值意味着 target-action 内部的 touch up(如果有)将被忽略,而是显示菜单。

    【讨论】:

      猜你喜欢
      • 2020-11-08
      • 1970-01-01
      • 2020-11-27
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 1970-01-01
      • 2021-08-20
      相关资源
      最近更新 更多