I'm trying to use a pull down menu in my app using the storyboard but I keep getting an error saying "Menu does not have a valid element for default selection"
. My setup looks like this:
I've successfully managed to implement a pull down menu using code, following this answer: How to show pull down button menu in IOS 14 swift but I'd like to know how to do it using a storyboard.
I think I'm missing the assignment of the UIMenuElement to my button, because when I remove the assignment in code button.menu = menu
it does't work either. I just can't seem to figure out how to connect the 2 using the storyboard.
You have to make sure that each of your menu commands have actions associated with them; otherwise, at run time, that exception is thrown.
So, after clicking on a menu command, go to the Connections Inspector and wire up an action to your code:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With