You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/09/14 02:20:58 UTC
ios commit: [CB-4803] Set new iOS 7 preferences for the UIWebView in
CDVViewController
Updated Branches:
refs/heads/master 14d79b481 -> 215da06ae
[CB-4803] Set new iOS 7 preferences for the UIWebView in CDVViewController
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/215da06a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/215da06a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/215da06a
Branch: refs/heads/master
Commit: 215da06ae3224fa0e20a541f3b17e1ec468c5320
Parents: 14d79b4
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Sep 13 17:20:50 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Sep 13 17:20:50 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVViewController.m | 82 +++++++++++++++++++++++++++--
1 file changed, 79 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/215da06a/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 6facdc1..e994f35 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -94,7 +94,7 @@
return self;
}
-- (id)initWithCoder:(NSCoder *)aDecoder
+- (id)initWithCoder:(NSCoder*)aDecoder
{
self = [super initWithCoder:aDecoder];
[self __init];
@@ -376,6 +376,82 @@
}
}
+ /*
+ * iOS 7.0 UIWebView properties
+ */
+ if (IsAtLeastiOSVersion(@"7.0")) {
+ SEL ios7sel = nil;
+ id prefObj = nil;
+
+ CGFloat gapBetweenPages = 0.0; // default
+ prefObj = [self settingForKey:@"GapBetweenPages"];
+ if (prefObj != nil) {
+ gapBetweenPages = [prefObj floatValue];
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setGapBetweenPages:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithFloat:gapBetweenPages] forKey:@"gapBetweenPages"];
+ }
+
+ CGFloat pageLength = 0.0; // default
+ prefObj = [self settingForKey:@"PageLength"];
+ if (prefObj != nil) {
+ pageLength = [[self settingForKey:@"PageLength"] floatValue];
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setPageLength:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithBool:pageLength] forKey:@"pageLength"];
+ }
+
+ NSInteger paginationBreakingMode = 0; // default - UIWebPaginationBreakingModePage
+ prefObj = [self settingForKey:@"PaginationBreakingMode"];
+ if (prefObj != nil) {
+ NSArray* validValues = @[@"page", @"column"];
+ NSString* prefValue = [validValues objectAtIndex:0];
+
+ if ([prefObj isKindOfClass:[NSString class]]) {
+ prefValue = prefObj;
+ }
+
+ paginationBreakingMode = [validValues indexOfObject:[prefValue lowercaseString]];
+ if (paginationBreakingMode == NSNotFound) {
+ paginationBreakingMode = 0;
+ }
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setPaginationBreakingMode:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithInteger:paginationBreakingMode] forKey:@"paginationBreakingMode"];
+ }
+
+ NSInteger paginationMode = 0; // default - UIWebPaginationModeUnpaginated
+ prefObj = [self settingForKey:@"PaginationMode"];
+ if (prefObj != nil) {
+ NSArray* validValues = @[@"unpaginated", @"lefttoright", @"toptobottom", @"bottomtotop", @"righttoleft"];
+ NSString* prefValue = [validValues objectAtIndex:0];
+
+ if ([prefObj isKindOfClass:[NSString class]]) {
+ prefValue = prefObj;
+ }
+
+ paginationMode = [validValues indexOfObject:[prefValue lowercaseString]];
+ if (paginationMode == NSNotFound) {
+ paginationMode = 0;
+ }
+ }
+
+ // property check for compiling under iOS < 7
+ ios7sel = NSSelectorFromString(@"setPaginationMode:");
+ if ([self.webView respondsToSelector:ios7sel]) {
+ [self.webView setValue:[NSNumber numberWithInteger:paginationMode] forKey:@"paginationMode"];
+ }
+ }
+
if ([self.startupPluginNames count] > 0) {
[CDVTimer start:@"TotalPluginStartup"];
@@ -661,8 +737,8 @@
/*
* Give plugins the chance to handle the url
*/
- for (NSString *pluginName in pluginObjects) {
- CDVPlugin *plugin = [pluginObjects objectForKey:pluginName];
+ for (NSString* pluginName in pluginObjects) {
+ CDVPlugin* plugin = [pluginObjects objectForKey:pluginName];
SEL selector = NSSelectorFromString(@"shouldOverrideLoadWithRequest:navigationType:");
if ([plugin respondsToSelector:selector]) {
if ((BOOL)objc_msgSend(plugin, selector, request, navigationType) == YES) {