菜单项已启用,但仍显示为灰色 [英] menu item is enabled, but still grayed out
问题描述
我有一个菜单,其中包含在界面生成器中创建的多个项目.在那里看起来不错,并选中了启用".
但是当我运行应用程序时,所有菜单项都是灰色的.
I have a menu with several items created in interface builder. It looks fine there and 'enabled' is checked.
But when I run application, all menu items are grayed out.
我已经检查过isEnabled
,它返回true.
I've checked isEnabled
, it returns true.
此外,以编程方式创建的菜单项(使用initWithTitle
且不使用界面生成器)也可以正常工作.
Also, menu items created programmatically (with initWithTitle
and without interface builder) work just fine.
我在这里错过了什么吗?我真的是OSX开发的新手(实际上,这是我的第一天).
谢谢
Am I missing something here? I'm really quite new to OSX development (in fact, this is my first day).
Thank you
推荐答案
万一有人用谷歌搜索它并从中受益,则声明了'Action'方法而没有:(id)sender
参数:
In case somebody might google this out and benefit, 'Action' method was declared without :(id)sender
parameter:
-(IBAction) quit;
奇怪的是,NSMenuItem
中的setAction
方法将其吃掉了,没有抱怨.哦,很好.
Strangely, setAction
method in NSMenuItem
ate it and didn't complain. Oh well.
这篇关于菜单项已启用,但仍显示为灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!