2017-10-12 37 views
0

這裏是我的代碼,我不確定如何AirPrint UILabel。 如果任何人都可以幫助我,將不勝感激。我想知道如何在swift中快速打印UILabel

@IBOutlet weak var cityLbl:UILabel!

@IBAction func printButton(_ sender: Any) { 

    self.printText() 

} 

func printText() { 
    let printController = UIPrintInteractionController.shared 

    let printI = UIPrintInfo(dictionary: nil) 

    printI.jobName = "printing this image" 
    printI.outputType = .general 

    printController.printInfo = printI 


    printController.printingItem = cityLbl 


    printController.present(animated: true) { (_, isPrinted, error) in 

     if error == nil { 
      if isPrinted { 
       print("image is printed") 
      } else { 
       print("image is not printed") 
      } 
     } 
    } 

} 

回答

0

你檢查是這個產品的可打印或不

func printText() { 
    if UIPrintInteractionController.canPrint(cityLbl) { 
     //your code 
    } 
}