2016-10-04 152 views
2

我有一個應用程序派生自Xcode可可應用程序模板,可以在El Capitan上正確打印,但在Sierra上引入了一個帶有陰影框的全方位釐米邊距。將邊距值(在viewController的viewDidLoad中的共享實例中)更改爲較大的正值會使邊距變大,但將邊距值減小到零仍會留下邊距和陰影框。該圖像是打印預覽的屏幕截圖。我想回到讓PDF佔據整個打印頁面。查看File/Print的菜單顯示它執行firstResponder print :.我應該嘗試重寫此功能嗎?但是,如果下面的代碼被執行不起作用,這會有什麼好處呢?在macOS中更改NSPrintInfo Sierra

NSPrintInfo *PageDefaults = [NSPrintInfo sharedPrintInfo]; 
[PageDefaults setBottomMargin:0]; 
[PageDefaults setLeftMargin:0]; 
[PageDefaults setRightMargin:0]; 
[PageDefaults setTopMargin:1]; 

enter image description here

如果我增加了頂部和左側邊緣在上面的代碼120,打印修改: enter image description here

,故事情節表明,我只使用一個PDF瀏覽控制填充整個viewController場景 enter image description here

最後,屏幕上的viewController顯示它看起來應該是: enter image description here

+0

如何打印什麼?也許視圖類改變了。我的簡單測試應用程序不打印邊框。 – Willeke

+0

與其說您可能在Xcode 8中創建了該應用程序,然而我的應用程序最初是在幾年前在Xcode 5或6中創建的!希望我的編輯能讓問題更清楚。 – Nick

+0

該項目是在OS X 10.10和Xcode 6.4中創建的。我會嘗試一個PDFView。這不是10.12中PDFView的唯一問題。 – Willeke

回答

1

-[PDFView print:] 10.10調用printWithInfo:autoRotate:pageScaling:。在10.12 -[PDFView print:]調用printOperationWithView:並打印背景。解決方案:創建PDFView的子類,覆蓋print:並致電printWithInfo:autoRotate:pageScaling:

- (void)print:(id)sender { 
    [self printWithInfo:[NSPrintInfo sharedPrintInfo] autoRotate:YES pageScaling:kPDFPrintPageScaleToFit]; 
} 
+0

絕對完美!謝謝。 – Nick