我已經編程創建了一個NSPopUpButton,並且爲我的選擇創建了一個數組,我如何爲每個單獨的數組選擇創建一個setAction?謝謝!PopUpButton的設置操作
NSRect buttonRect = NSMakeRect(1705, 145, 78, 50);
//Button Array. When I pick the choice it closes the diologue box
NSArray *newArray;
NSString *color1 = @"Blue Color";
NSString *color2 = @"Green Color";
NSString *color3 = @"Clear Color";
newArray = [NSArray arrayWithObjects: color1, color2, color3, nil];
NSPopUpButton *button = [[NSPopUpButton alloc] initWithFrame:buttonRect pullsDown:YES];
[self addSubview:button];
[button addItemsWithTitles:newArray];
//want my action for each individual string
[button setAction:@selector(changeFilterColor)];
-(void) changeFilterColor
{
NSLog(@"colorChanged");
}
它看起來像你缺少一個[button setTarget:self] – johndpope 2015-02-17 04:16:59