2016-05-24 11 views
5

私はメインコントローラでこのNSViewのためのボタンに次のアクションを割り当てることにより、NSPopoverのカスタムNSViewのために印刷機能を行っている:それは働いているが、印刷ウィンドウが用紙サイズとのためのオプションを持っていないココアで印刷をセットアップするには、迅速?

@IBOutlet var plasmidMapIBOutlet: PlasmidMapView! 

@IBAction func actionPrintfMap(sender: AnyObject) 
{ 
    plasmidMapIBOutlet.print(sender) 
} 

オリエンテーション、以下のスクリーンショットを参照してください。 enter image description here

  1. 印刷ウィンドウでこれらのオプションを取得するにはどうすればよいですか?
  2. NSViewを印刷可能領域に合わせるにはどうしたらいいですか?今はそれが合いません。

私はいくつかの瞬間を見つけましたが、完全ではありません。ですから、私は次のコードで印刷をセットアップできます

@IBAction func actionPrintMap(sender: AnyObject) 
{ 
    let printInfo = NSPrintInfo.sharedPrintInfo() 
    let operation: NSPrintOperation = NSPrintOperation(view: plasmidMapIBOutlet, printInfo: printInfo) 
    operation.printPanel.options = NSPrintPanelOptions.ShowsPaperSize 
    operation.printPanel.options = NSPrintPanelOptions.ShowsOrientation 
    operation.runOperation() 

    //plasmidMapIBOutlet.print(sender) 
} 

しかし、私はまだ問題があります。上記のコードから、私はオリエンテーション(最後、ShowsOrientation)しか取得できませんが、PaperSizeとオリエンテーションの両方は取得できません。 ShowsPaperSizeとShowsOrientationの両方をどのように管理できますか?

+0

あなたは(https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Printing/osxp_aboutprinting/osxp_aboutprt.html#//apple_ref/doc [Mac用印刷プログラミングガイド]を読みました/ uid/10000083-SW1)? – Willeke

+0

@Willekeはい、私は質問を更新しました。今ではShowsPaperSizeとShowsOrientationの両方のオプションを持つことはできません。どのように私は両方を持つことができますか? – VYT

答えて

2

最後に私は簡単な答えを見つけましたが、リンゴのドキュメントからはそれほど明白ではありません。

operation.printPanel.options.insert(NSPrintPanelOptions.showsPaperSize) 
    operation.printPanel.options.insert(NSPrintPanelOptions.showsOrientation)