Print panel accessory view shows in OS X 10.11, but not in 10.10 and 10.9

276 views Asked by At

My OS X app supports 10.9 - 10.11. I try to add some options to a printing operation by adding a print accessory view like this:

MyPrintView *printView = [[MyPrintView alloc] initWithData: [self myData]];
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView: printView];
NSPrintPanel *printPanel = [printOperation printPanel];
[printPanel addAccessoryController:[[MyPrintAccessory alloc] init]];
if (printOperation)
{
    [printOperation runOperationModalForWindow:_window delegate:_window didRunSelector:nil contextInfo:nil];
}

The accessory view is defined by a controller

@interface MyPrintAccessory : NSViewController <NSPrintPanelAccessorizing>

and a view defined in a xib file.

All works perfectly as expected in El Capitan, but in Yosemite and Mavericks while the print panel let's me choose my accessory in the pop-up button, if I choose it, nothing is displayed, the space where the accessory view should be displayed remains empty. No error messages are generated neither at compile nor at runtime.

Does anybody have a hint on how to solve this, or a hint, how to search for the cause of this behaviour?

2

There are 2 answers

0
cometheart On

I had the same problem. I solved it by setting the option "Use Auto Layout" to off of my print accessory view nib file.

1
A O On

My application does the same thing, and works in 10.10

There is a slight difference, but to preface: My application is an NSDocument-based application. When printing, I grab the NSPrintInfo from the NSDocument, and feed it to my print method (the code you have embedded in your question)

Looks like this:

[printView requestPrintWithPrintInfo:[doc printInfo]];

Then, instead of calling -printOperationWithView:, I call -printOperationWithView:printInfo:, and I pass the printInfo that came from the sender

From Apple's docs, you should call -printOperationWithView when:

/* Slight conveniences, for use when the application's global NSPrintInfo is appropriate. Each of these methods invokes [NSPrintInfo sharedPrintInfo] and then invokes the like-named method listed above.

To me it sounds like it should work anyways, but like I said that's seemingly the only difference in our code