gpt4 book ai didi

cocoa - 如何在 Cocoa 打印对话框中获取 "Page Attributes"选项?

转载 作者:行者123 更新时间:2023-12-03 16:06:09 25 4
gpt4 key购买 nike

我正在编写的程序在 OS X 10.5 Leopard 下运行。我的目标的基本 SDK 和部署目标均设置为 Mac OS X 10.5。当我启动打印时,我的打印对话框不显示“页面属性”选项,用户可以在其中选择页面大小和方向。

No Page Attributes

在 Leopard 下运行的其他程序确实显示此选项:

Yes Page Attributes

这是启动打印的代码:

-(void)print {
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
TemperaturePressurePrintView *printView = [[TemperaturePressurePrintView alloc] initWithFrequencies:frequencies];
if (printView) {
[[NSPrintOperation printOperationWithView:printView printInfo:printInfo] runOperation];
[printView release];
}
}

我需要做什么才能让页面属性显示在我的打印对话框中?

最佳答案

这是一件很难搜索的事情,因为结果主要是关于使用打印面板,而不是编程。终于找到线索了on Cocoabuilder其中提到了 NSPrintPanelOptionsNSPrintPanel-setOptions: 方法。

这段代码完成了我的需要:

-(void)print {
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
TemperaturePressurePrintView *printView = [[TemperaturePressurePrintView alloc] initWithFrequencies:frequencies];
if (printView) {
NSPrintOperation *op = [NSPrintOperation printOperationWithView:printView printInfo:printInfo];
[[op printPanel] setOptions:[[op printPanel] options] | NSPrintPanelShowsPageSetupAccessory];
[op runOperation];
[printView release];
}
}

关于cocoa - 如何在 Cocoa 打印对话框中获取 "Page Attributes"选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8840678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com