我使用了这个来源http://www.cats.rwth-aachen.de/library/programming/cocoa
创建我的自定义工作表。
我NSPanel
在现有的 .xib 文件中创建了一个对象并与IBOutlet
我的源代码:
。H
@interface MainDreamer : NSWindow <NSWindowDelegate>
{
...
NSPanel *newPanel;
}
...
@property (assign) IBOutlet NSPanel *newPanel;
.m
@dynamic newPanel;
...
//this method is wired with button on main window and calls a sheet
- (IBAction)callPanel:(id)sender
{
[NSApp beginSheet:newPanel
modalForWindow:[self window] modalDelegate:self
didEndSelector:@selector(myPanelDidEnd:returnCode:contextInfo:)
contextInfo: nil]; //(__bridge void *)[NSNumber numberWithFloat: 0]
}
//this method is wired with cancel and ok buttons on the panel
- (IBAction)endWorkPanel:(id)sender
{
[newPanel orderOut:self];
[NSApp endSheet:newPanel returnCode:([sender tag] == 9) ? NSOKButton : NSCancelButton];
}
//closing a sheet
- (void)myPanelDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSCancelButton) return;
else{
return;
}
}
所以callPanel
工作正常,工作表出现,但我无法与工作表上的控件(带按钮)交互。他们不会对点击做出反应(甚至在视觉上)。
问题出在哪里?