2

我正在使用 NSSavePanel 并使用 IKSaveOptions 在其上添加附件视图。

在优胜美地之前它运行良好,然后优胜美地导致崩溃:NSSavePanel 在优胜美地崩溃

我在一年前实施了这个修复。现在 El Capitan 出现了,并且发生了类似的崩溃,但发生在不同的位置。

当前代码:

    // Let the user choose an output file, then start the process of writing samples
    NSSavePanel *savePanel = [NSSavePanel savePanel];
    _saveOptions = [[IKSaveOptions alloc] initWithImageProperties: _imageProperties
                                                      imageUTType: _imageUTType];

    [_saveOptions addSaveOptionsAccessoryViewToSavePanel: savePanel];
    NSView * accessoryView = savePanel.accessoryView;
    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8)
    {
        [accessoryView setTranslatesAutoresizingMaskIntoConstraints:YES];
    }
    [savePanel setCanSelectHiddenExtension:YES];
    [savePanel setNameFieldStringValue:[[_window representedFilename] lastPathComponent]];
    [savePanel beginSheetModalForWindow:_window completionHandler:^(NSInteger result) {
        if (result == NSFileHandlingPanelOKButton)
            [self savePanelDidEnd:savePanel returnCode:result];
    }];

上面的代码在 Yosemite 上完美运行,但是在 El Capitan 上,当我尝试使用异常调用 addSaveOptionsAccessoryViewToSavePanel 时抛出异常:

2015-09-07 09:39:56.224 IKImageViewDemo[1565:108561] An uncaught exception was raised
2015-09-07 09:39:56.224 IKImageViewDemo[1565:108561] Setting autoresizing constraints when autoresizing is off
2015-09-07 09:39:56.231 IKImageViewDemo[1565:108561] (
    0   CoreFoundation                      0x00007fff974c9a22 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff933b373c objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff974c97fa +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00007fff8c2178ec -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
    4   AppKit                              0x00007fff964ae2d7 -[NSView(NSConstraintBasedLayout) _setAutoresizingConstraints:] + 143
    5   AppKit                              0x00007fff9648b5ca -[NSView setTranslatesAutoresizingMaskIntoConstraints:] + 162
    6   ImageKit                            0x00007fff8aabc6d8 -[IKSaveOptionsHandler setSavePanel:] + 260
    7   IKImageViewDemo                     0x0000000100002b3c -[Controller saveImage:] + 204
    8   libsystem_trace.dylib               0x00007fff9923d082 _os_activity_initiate + 75
    9   AppKit                              0x00007fff966ac685 -[NSApplication sendAction:to:from:] + 460

那么我现在如何设置它以在 El Capitan 上工作呢?由于已经抛出异常,我什至无法进入附件视图这一事实使这变得非常困难。

4

0 回答 0