2012-02-21 85 views
1

我加載紙張到我的主要的.xib,薄片是面板和我沒有問題,顯示板或關閉,但是當我關閉它我得到一個錯誤信息:可可beginSheet:didEndSelector拋出一個錯誤

2012-02-21 11:10:12.142 CollectionTest2[23277:10b] *** - 
[AppController customSheetDidClose:returnCode:contextInfo:]: unrecognized selector sent to instance 0x359c00 

這裏是我的代碼:

/*Sheet Methods*/ 

- (void)showCustomSheet: (NSWindow *)window { 

    [NSApp beginSheet: panFilenameEditor modalForWindow: window modalDelegate: self didEndSelector: @selector(customSheetDidClose:returnCode:contextInfo:) contextInfo: nil]; 
} 

- (IBAction)closeCustomSheet:(id)sender { 

    [panFilenameEditor orderOut:self]; 
    [NSApp endSheet:panFilenameEditor]; 
} 

- (void) customSheetDidClose { 

    NSLog(@"sheet did close"); 
} 

回答

1

在你showCustomSheet方法,你告訴紙張調用選擇customSheetDidClose:returnCode:contextInfo:您的應用程序控制器。但是沒有這樣的方法。

解決辦法有兩個:

  • 要麼通過@selector(customSheetDidClose)在您的來電beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
  • 或重命名你customSheetDidCloseMethod- (void)customSheetDidClose:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+0

@DD - 謝謝,我只是在看文檔再次不理解,但你的解釋是有道理的。應用程序現在工作正常。 – PruitIgoe 2012-02-21 17:14:29