这是我在Swift airprinting中使用的beta 6代码,它运行良好:
当然,beta 7版本在第一个变量行上出现了“UIPrintInteractionController类型的可选值未解包;你是想使用!还是?”,导致程序出现问题。不幸的是,XCode建议的修复方法并不能解决这个问题,而我自己也不够聪明去解决它!
@IBAction func button3Tapped() {
var pic:UIPrintInteractionController = .sharedPrintController()
var viewpf:UIViewPrintFormatter = myTextView.viewPrintFormatter()
pic.delegate = self
pic.showsPageRange = true
pic.printFormatter = viewpf
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
pic.presentFromRect(self.myButton3.frame, inView:self.view, animated:true, completionHandler: nil)
} else {
pic.presentAnimated(true, completionHandler: nil)
}
}
当然,beta 7版本在第一个变量行上出现了“UIPrintInteractionController类型的可选值未解包;你是想使用!还是?”,导致程序出现问题。不幸的是,XCode建议的修复方法并不能解决这个问题,而我自己也不够聪明去解决它!