Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Storyboard 中设置 aMenu和Menu Items,并希望一个菜单项在两种状态之间切换,例如开/关、摄氏度/华氏度等。
Menu
Menu Item
但是,从菜单项到界面控制器的控制拖动并不能让我创建一个出口,而只能选择创建一个动作。因此,尽管我可以设置一个动作来在两种状态之间切换,但我无法更改它title并image显示当前按钮状态。
title
image
有没有办法在 WatchKit 中正确实现这一点?
是的,你可以这样做——无论何时你想切换你的状态——清除菜单项:
[self clearAllMenuItems];
然后设置新的菜单项:
[self addMenuItemWithImageNamed:@"myImage" title:@"action title" action:@selector(actionMethod)];