I would like to present my UIMenu from UIButton when button is tapped. Because in the beginning I need to update children of UIMenu.
let menuButton: UIButton = {
let button = UIButton()
button.menu = UIMenu(title: "title")
button.showsMenuAsPrimaryAction = true
return button
}()
func setupView() {
menuButton.rx.tap.bind {
let action = UIAction(title: "title", image: nil, handler: { _ in })
menuButton.menu.replacingChildren([action])
// present menu, how?
}.disposed(by: disposeBag)
}
Nothing happens here. My action for tap is registered with RxSwift. How can I do it to present the menu?