我只想在自定义的NStextFieldCell中添加带有setAction的简单NSButton ... 但我的处理器占用了100%......
我的自定义NStextFieldCell类中的代码如下:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
...
NSButton *myButton = [[NSButton alloc] initWithFrame:NSMakeRect(cellFrame.origin.x+200, cellFrame.origin.y+5, 30, 30)];
[controlView addSubview: myButton];
[myButton setTitle: @"Button title!"];
[myButton setButtonType:NSMomentaryLightButton];
[myButton setBezelStyle:NSRoundedBezelStyle];
[myButton setTarget:self];
[myButton setAction:@selector(myAction)];
...
}
任何想法? 感谢