2016-08-12 90 views
1

我必须在横向模式下发送Airprint我的WebView。 但是在设置我的方向时出现错误。 我写了这个代码如何将Airprint方向设置为快速横向显示?

let printcontroller = UIPrintInteractionController.sharedPrintController() 
    let printinfo = UIPrintInfo(dictionary:nil) 
    printinfo.jobName = "Printing Label" 
    printinfo.outputType = UIPrintInfoOutputType.General 
    printcontroller.printInfo = printinfo 
    printinfo.orientation = UIDeviceOrientationLandscapeRight 
    printcontroller.printFormatter = myWeb.viewPrintFormatter() 
    printcontroller.showsNumberOfCopies = false 
    printcontroller.presentAnimated(true) { (_, isPrinted, error) in 
     if error == nil 
     { 
      if isPrinted 
      { 
       print ("Printed Successfully") 
      } else 
      { 
       print ("Printing failed") 
      } 

     } 
    } 
    self.performSegueWithIdentifier("finaltohome", sender: nil) 

enter image description here

请帮助我。

回答

0

它现在枚举:UIDeviceOrientation.LandscapeLeftUIDeviceOrientation.LandscapeRight。你需要import UIKit

0

UIPrintInfo有它自己的方向enum UIPrintInfoOrientation它有两个价值,肖像或风景。

printinfo.orientation = UIPrintInfoOrientation.landscape 
0

我使用以下命令:

`let printInfo = UIPrintInfo(dictionary:nil) 
printInfo.outputType = UIPrintInfoOutputType.general 
printInfo.jobName = "print Job" 
printInfo.orientation = .landscape 
printController.printInfo = printInfo` 
相关问题