I have created my NSPopUpButton programmatically with the following code
[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");
}
When I click the popUpButton,menu items of popUpButton are disabled.
When I use interfacebuilder,just it is working fine with the IBAction.
Why this setAction is not working for NSPopUpButton?
Looks like you’re not setting a target object to send the message to. So, in code, add:
assuming the
popUpAction:method is in the same class.When you’re using Interface Builder it’s wiring-up the selector action to the target.
From the documentation for this call:
In your case, there is no object responding to the message.