菜单项已启用,但仍显示为灰色 [英] menu item is enabled, but still grayed out

查看:140
本文介绍了菜单项已启用,但仍显示为灰色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个菜单,其中包含在界面生成器中创建的多个项目.在那里看起来不错,并选中了启用".
但是当我运行应用程序时,所有菜单项都是灰色的.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆