4

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:

pull down menu with menu items

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.

burnsi
  • 6,194
  • 13
  • 17
  • 27
Dennis
  • 53
  • 4

1 Answers1

3

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:

enter image description here

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83