【问题标题】:cocoa beginSheet: didEndSelector throwing an error可可 beginSheet:didEndSelector 抛出错误
【发布时间】:2012-02-21 17:01:40
【问题描述】:

我正在将工作表加载到我的主 .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");
} 

【问题讨论】:

    标签: cocoa nsapplication cocoa-sheet


    【解决方案1】:

    在您的showCustomSheet 方法中,您告诉工作表调用应用控制器上的选择器customSheetDidClose:returnCode:contextInfo:。但是没有这样的方法。

    有两种解决方案:

    • 将您的电话中的@selector(customSheetDidClose) 传递给beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
    • 或将您的 customSheetDidCloseMethod 重命名为 - (void)customSheetDidClose:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo

    【讨论】:

    • @DD - 谢谢,我只是再次查看文档并且不理解它,但您的解释是有道理的。应用程序现在运行良好。
    猜你喜欢
    • 2014-02-09
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-01
    • 1970-01-01
    相关资源
    最近更新 更多