2015-05-08 1 views
-1

Я рассмотрел другие вопросы, похожие на поиск, но кодировка отличается и не помогает мне. У меня есть код ниже, который прекрасно печатает локальные файлы PDF в симуляторе iPhone, но он не будет работать в симуляторе iPad. Кнопка не делает ничего, и эта ошибка в журнале управления: ВНИМАНИЕ: Вызов - [UIPrintInteractionController presentAnimated: completionHandler:] на IPadAirPrint для iPhone работает, но не iPad Xcode 6.3

Это Xcode 6,3

@IBAction func print(sender: AnyObject) { 
    var pdfLoc = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource("Drop-Withdrawal Form 09-22-14", ofType:"pdf")!) 
    // 1 
    let printController = UIPrintInteractionController.sharedPrintController()! 
    // 2 
    let printInfo = UIPrintInfo(dictionary:nil)! 
    printInfo.outputType = UIPrintInfoOutputType.General 
    printInfo.jobName = "print Job" 
    printController.printInfo = printInfo 
    // 3 


    printController.printingItem = pdfLoc 
    // 4 
    printController.presentAnimated(true, completionHandler: nil) } 
+0

Кто-нибудь? Пожалуйста, помогите мне. –

ответ

0

Вместо:

// 4 
printController.presentAnimated(true, completionHandler: nil) 

использование (если вы хотите использовать barButtonItem для печати с):

printController.presentFromBarButtonItem(printButton, animated: true, completionHandler: nil) 

, если вы хотите использовать обычный UIButton изнутри представления, используйте:

printController.presentFromRect(CGRect, inView:, animated:, completionHandler:) 

Надеюсь, это поможет!

+0

Также убедитесь, что установлен симулятор принтера, чтобы вы могли проверить свой результат. – Dominic