I am using NSSavePanel to save image.
I have used IKSaveOption which gets added to the NSSavePanel. When save panel tries to open the sheet for window it crashes saying -
*** Assertion failure in -[IKSaveOptionsContainer _didChangeHostsAutolayoutEngineTo:], /SourceCache/AppKit/AppKit-1343.14/Layout.subproj/NSView_Layout.m:577 - Should translate autoresizing mask into constraints if _didChangeHostsAutolayoutEngineTo:YES.
I am following 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 on Yosemite. Are there any layout changes in the new OS API?
El Capitan + Yosemite workaround is to avoid adding it with addSaveOptionsAccessoryViewToSavePanel but use addSaveOptionsToView + manually update extension using allowedFileTypes
Update2: The solution turns out to be simple.
Update: The below workaround does not change the filename's extension and depending on how you save the file, the new format request may not be honored.
I found a workaround, and I filed a bug with Apple (20595916). The workaround isn't great because the superview's size might be inadequate and clip the controls for the image options.