watchkitwkinterfacemenu

Is there a way of disabling a WKInterfaceMenu?


I have a WKInterfaceMenu added to the storyboard which is working great. However, once used, I don't want the menu to appear for a second time.

Is there a way of preventing the menu from appearing?


Solution

  • You can definitely do this, but you need to do things a bit differently.

    First off, don't set up the context menu in the storyboard. Instead, set up all the menu items programmatically. You can add and remove menu items using the addMenuItemWithImageNamed and clearAllMenuItems methods on your WKInterfaceController instance.

    You want to set up all your menu items initially, then remove them in all your callback methods for each menu item. That way, they'll be there at first, and will be removed once you select one of them.