Print-View positioning on iPad

This commit is contained in:
Sebastián Katzer
2014-10-13 23:31:12 +02:00
parent 268f1b652d
commit 15aa295cf6
4 changed files with 87 additions and 4 deletions

View File

@@ -71,9 +71,11 @@
UIPrintInteractionController* controller = [self printController];
CGRect rect = [self convertIntoRect:[settings objectForKey:@"bounds"]];
[self adjustPrintController:controller withSettings:settings];
[self loadContent:content intoPrintController:controller];
[self presentPrintController:controller];
[self presentPrintController:controller fromRect:rect];
}
/**
@@ -184,10 +186,9 @@
* The prepared print controller with a content
*/
- (void) presentPrintController:(UIPrintInteractionController*)controller
fromRect:(CGRect)rect
{
if(CDV_IsIPad()) {
CGRect rect = CGRectMake(40, 30, 0, 0);
[controller presentFromRect:rect inView:self.webView animated:YES completionHandler:
^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
CDVPluginResult* pluginResult =
@@ -209,6 +210,23 @@
}
}
/**
* Convert Array into Rect object.
*
* @param bounds
* The bounds
*
* @return
* A converted Rect object
*/
- (CGRect) convertIntoRect:(NSArray*)bounds
{
return CGRectMake([[bounds objectAtIndex:0] floatValue],
[[bounds objectAtIndex:1] floatValue],
[[bounds objectAtIndex:2] floatValue],
[[bounds objectAtIndex:3] floatValue]);
}
/**
* Checks either the printing service is avaible or not.
*