From 268f1b652d20e24c778c2387d387567db1964349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Tue, 7 Oct 2014 21:20:09 +0200 Subject: [PATCH] IPad+iOS8 incompatibility (Fixes #26) --- CHANGELOG.md | 3 ++- README.md | 4 ++++ src/ios/APPPrinter.m | 29 ++++++++++++++++++++++------- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4fed4..d70d9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## ChangeLog -#### Version 0.7.0 (not yet released) +#### Version 0.7.1 (not yet released) - [bugfix:] `isAvailable` does not block the main thread anymore. +- [bugfix:] iPad+iOS8 incompatibility (Thanks to __zmagyar__) #### Version 0.7.0 (12.09.2014) - Android Printing Framework support diff --git a/README.md b/README.md index 1a11d4b..7cf230e 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,10 @@ cordova plugin rm de.appplant.cordova.plugin.printer ## ChangeLog +#### Version 0.7.1 (not yet released) +- [bugfix:] `isAvailable` does not block the main thread anymore. +- [bugfix:] iPad+iOS8 incompatibility (Thanks to __zmagyar__) + #### Version 0.7.0 (12.09.2014) - Android Printing Framework support - [__change__:] Renamed `isServiceAvailable` to `isAvailable` diff --git a/src/ios/APPPrinter.m b/src/ios/APPPrinter.m index 80ab2ef..6eadc31 100755 --- a/src/ios/APPPrinter.m +++ b/src/ios/APPPrinter.m @@ -20,6 +20,7 @@ */ #import "APPPrinter.h" +#import @interface APPPrinter () @@ -184,14 +185,28 @@ */ - (void) presentPrintController:(UIPrintInteractionController*)controller { - [controller presentAnimated:YES completionHandler: - ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { - CDVPluginResult* pluginResult = - [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + if(CDV_IsIPad()) { + CGRect rect = CGRectMake(40, 30, 0, 0); - [self.commandDelegate sendPluginResult:pluginResult - callbackId:_callbackId]; - }]; + [controller presentFromRect:rect inView:self.webView animated:YES completionHandler: + ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { + CDVPluginResult* pluginResult = + [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + + [self.commandDelegate sendPluginResult:pluginResult + callbackId:_callbackId]; + }]; + } + else { + [controller presentAnimated:YES completionHandler: + ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { + CDVPluginResult* pluginResult = + [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + + [self.commandDelegate sendPluginResult:pluginResult + callbackId:_callbackId]; + }]; + } } /**