Tôi đang cố gắng thiết lập in qua ứng dụng iPad, trong đó nhấp vào In sẽ in chế độ xem với tất cả nội dung của nó. Đây là những gì tôi đã cố gắng (kéo nhau từ một vài ví dụ trực tuyến):Nội dung AirPrint của UIView
// 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)
Tuy nhiên, tôi cũng đọc here rằng viewPrintFormatter
là chỉ dành cho những UIWebView, UITextView, và MKMapView, là đúng?
Khi tôi in bằng cách này (sử dụng trình mô phỏng máy in), tôi chỉ nhận được một trang trống; đã thử với nhiều máy in/khổ giấy khác nhau.
Mọi hướng dẫn đều được đánh giá cao!
Điều gì sẽ xảy ra khi bạn thử? – Undo
Câu hỏi không được cập nhật của tôi –