2016-08-12 124 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` 
相關問題