[myPopUpbutton insertItemWithTitle:@"--Select one--" atIndex:0];[myPopUpbutton addItemsWithTitles:[NSArray arrayWithObjects:@"1.One",@"Two",@"Three",nil]];[myPopUpbutton sizetoFit];[myPopUpbutton setAction:@selector(popUpAction:)];[fullbrowserVIEw addSubvIEw: myPopUpbutton];//PopUp Action-(voID)popUpAction:(ID)sender{ NSLog(@"popUpAction");}
当我单击popUpbutton时,popUpbutton的菜单项被禁用.
当我使用interfacebuilder时,它正好适用于IBAction.
为什么这个setAction不能用于NSPopUpbutton?
解决方法 看起来您没有设置目标对象来发送消息.所以,在代码中添加:[myPopUpbutton setTarget:self];
假设popUpAction:方法在同一个类中.
当您使用Interface Builder时,它会将选择器 *** 作连接到目标.
从此电话的文档:
- (voID)setTarget:(ID)anObject
If anObject is
nil
but the control still has a valID action message assigned,the application follows the responder chain looking for an object that can respond to the message.
在您的情况下,没有对象响应该消息.
总结以上是内存溢出为你收集整理的macos – NSPopUpButton的SetAction正在禁用我的popUpButton全部内容,希望文章能够帮你解决macos – NSPopUpButton的SetAction正在禁用我的popUpButton所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)