NSSavePanel falls on Yosemite

I use NSSavePanel to save image.

I used IKSaveOption , which is added to the NSSavePanel. When the save panel tries to open a sheet for a window, it displays a message:

*** Validation error in - [IKSaveOptionsContainer _didChangeHostsAutolayoutEngineTo:], / SourceCache / AppKit / AppKit-1343.14 / Layout.subproj / NSView_Layout.m: 577 - Must translate the autoresist mask to restrictions if _didChangeHoutsAutoAtolol.

I follow this code:

NSSavePanel *savePanel = [NSSavePanel savePanel];
    [savePanel setDirectoryURL:[NSURL URLWithString:NSHomeDirectory()]];
    [savePanel setDelegate:self];
    [savePanel setPrompt:NSLocalizedString(@"save",nil)];
    [savePanel setAllowedFileTypes:[NSArray  arrayWithObjects:@"png",@"jpeg",nil]];
      IKSaveOptions * opt = [[IKSaveOptions alloc] initWithImageProperties:nil
                                                          imageUTType:(NSString *)kUTTypePNG];
    [opt addSaveOptionsAccessoryViewToSavePanel:savePanel];
    [savePanel setExtensionHidden:NO];

   [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){.....
}

This code works in Maverick, but not in Yosemite. Are there any layout changes in the new OS API?

+4
2

Update2: .

[self.saveOptions addSaveOptionsAccessoryViewToSavePanel:savePanel];
savePanel.accessoryView.translatesAutoresizingMaskIntoConstraints = YES;

: , , .

, Apple (20595916). , .

NSView* view = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 400, 200)];
view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
savePanel.accessoryView = view;

[self.saveOptions addSaveOptionsToView:view];
+3

El Capitan + Yosemite , addSaveOptionsAccessoryViewToSavePanel, addSaveOptionsToView +

var saveOptions = IKSaveOptions()
var imageUTType = kUTTypeTIFF
var imageProperties: NSDictionary = Dictionary<String, String>()
var panel : NSSavePanel?

internal func prepareExportSavePanel(savePanel : NSSavePanel) -> Bool {
    panel = savePanel
    saveOptions = IKSaveOptions(imageProperties: imageProperties , imageUTType: imageUTType)
    saveOptions.delegate = self
    if #available(macOS 10.14, *) { //might work on earlier versions
        saveOptions.addAccessoryView(to: savePanel)
    } else {
        savePanel.accessoryView = NSView(frame: NSRect(x: 0, y: 0, width: 500, height: 200))
        saveOptions.add(to: savePanel.accessoryView)
    }

    return true
}

override func saveOptions(saveOptions: IKSaveOptions!, shouldShowUTType utType: String!) -> Bool {
    if (utType == "com.ilm.openexr-image") {
        return false
    }
    return true
}

@objc dynamic func saveOptionsChanged(_ sender: Any?) {
    imageProperties = saveOptions.imageProperties
    imageUTType = saveOptions.imageUTType
    panel?.allowedFileTypes = [imageUTType as String]
}

@objc dynamic open var canCalculateEstimatedSize : Bool {
    return false
}
0

All Articles