1

メインの.xibにシートを読み込んでいます。シートはパネルであり、シートの表示や閉じに問題はありませんが、閉じるとエラーメッセージが表示されます。

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");
} 
4

1 に答える 1

1

メソッドでは、アプリコントローラーshowCustomSheetのセレクターを呼び出すようにシートに指示します。customSheetDidClose:returnCode:contextInfo:しかし、そのような方法はありません。

2つの解決策があります:

  • @selector(customSheetDidClose)への呼び出しを渡しますbeginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
  • または、名前をに変更customSheetDidCloseMethodします- (void)customSheetDidClose:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
于 2012-02-21T17:08:53.940 に答える