0

我使用了这个来源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工作正常,工作表出现,但我无法与工作表上的控件(带按钮)交互。他们不会对点击做出反应(甚至在视觉上)。

问题出在哪里?

4

1 回答 1

0

呵呵,我忘了

[newDreamPanel close];

applicationDidFinishLaunching方法。我写它是因为我希望面板在主窗口启动时不出现。

实际上,Visible At Launch面板的属性应该在 IB 中被激活。该close方法也有效,但副作用是面板上的所有控件都无法使用。

于 2012-02-11T07:06:51.610 回答