我試圖通過iPad應用程序設置打印,點擊Print將打印一個視圖及其所有內容。下面是我試了一下(從幾個例子拉到一起在線):UIView的AirPrint內容
// This is the View I want to print
// Just a 200x200 blue square
var testView = UIView(frame: CGRectMake(0, 0, 200, 200))
testView.backgroundColor = UIColor.blueColor()
let printInfo = UIPrintInfo(dictionary:nil)!
printInfo.outputType = UIPrintInfoOutputType.General
printInfo.jobName = "My Print Job"
// Set up print controller
let printController = UIPrintInteractionController.sharedPrintController()
printController!.printInfo = printInfo
// This is where I was thinking the print job got the
// contents to print to the page??
printController?.printFormatter = testView.viewPrintFormatter()
// Do it
printController!.presentFromRect(self.frame, inView: self, animated: true, completionHandler: nil)
不過,我也讀here即viewPrintFormatter
僅提供給UIWebView中,UITextView的,和的MKMapView,是正確的?
當我用這個打印(使用打印機模擬器),我只是得到一個空白頁;嘗試使用各種打印機/紙張尺寸。
任何指導非常感謝!
當你嘗試時發生了什麼? – Undo
我的壞 - 更新的問題 –