Hi, guys. I'm testing the new pop-up and pull-down buttons in iOS 15, but they do not show the pop-up menu when pressed (all the options in the Attributes Inspector panel are checked). They only work when I define the entire menu in code. My questions are:
- Is this because the feature was not implemented yet?
- If this is implemented later and we can define the menu in Interface Builder, how do you respond to a selection? In code, I can specify the action in the closure, but how do I do it if the menu is defined in Interface Builder?
This is how I define the menu from code, just in case someone needs to know:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let optionsClosure = { (action: UIAction) in
print(action.title)
}
myButton.menu = UIMenu(children: [
UIAction(title: "Option 1", state: .on, handler: optionsClosure),
UIAction(title: "Option 2", handler: optionsClosure),
UIAction(title: "Option 3", handler: optionsClosure)
])
}
}
Thanks JD