如何将Airprint方向设置为快速横向显示?
问题描述:
我必须在横向模式下发送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)
请帮助我。
答
它现在枚举:UIDeviceOrientation.LandscapeLeft
或UIDeviceOrientation.LandscapeRight
。你需要import UIKit
。
答
UIPrintInfo
有它自己的方向enum UIPrintInfoOrientation
它有两个价值,肖像或风景。
printinfo.orientation = UIPrintInfoOrientation.landscape
答
我使用以下命令:
`let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.general
printInfo.jobName = "print Job"
printInfo.orientation = .landscape
printController.printInfo = printInfo`