简体   繁体   English

如何在Airift中将Airprint方向设置为Landscape?

[英]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.LandscapeLeftUIDeviceOrientation.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.

相关问题 如何使用UINavigationController(Swift 2.0 iOS 9)强制设置风景方向 - How to force set Landscape Orientation with UINavigationController (Swift 2.0 iOS 9) 强制横向,Swift - Force Landscape orientation, Swift 如果应用程序设备的方向是纵向的,那么如何仅在iOS中为一个视图构建者设置强制横向,Swift 2.3 - if app device orientation is portrait how to set force landscape only for one view constroller in ios, swift 2.3 如何将mpMoviePlayerController方向设置为锁定为横向模式? - How to set the mpMoviePlayerController orientation locked to landscape mode? 如何设置iOS设备方向仅景观? - How to set iOS device orientation only landscape? 如何在横向方向上设置垂直约束(故事板) - How to set vertical constraints in landscape orientation (Storyboard) Swift 中集合视图的横向方向 - Landscape orientation for Collection View in Swift 如何快速检查设备方向是横向左侧还是右侧? - How to check if device orientation is landscape left or right in swift? 如何快速对整个屏幕进行AirPrint打印 - how to AirPrint a picture of the whole screen in swift 设置视图控制器的方向横向 - Set orientation landscape for a view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM