[英]How to set the Airprint orientation to Landscape in swift?
I have to send an Airprint my WebView in landscape mode. 我必须以横向模式发送Airprint我的WebView。 But I am getting error while setting up my orientation.
但是在设置我的方向时我遇到了错误。 I have written this code
我写了这段代码
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)
Please help me. 请帮我。
It's enums now: UIDeviceOrientation.LandscapeLeft
or UIDeviceOrientation.LandscapeRight
. 它现在是枚举:
UIDeviceOrientation.LandscapeLeft
或UIDeviceOrientation.LandscapeRight
。 And you need to import UIKit
. 而且你需要
import UIKit
。
UIPrintInfo
有自己的方向枚举UIPrintInfoOrientation
,它有两个值,纵向或横向。
printinfo.orientation = UIPrintInfoOrientation.landscape
I use the following: 我使用以下内容:
`let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.general
printInfo.jobName = "print Job"
printInfo.orientation = .landscape
printController.printInfo = printInfo`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.