incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject git commit: Added UIWebViewBounce key to PhoneGap.plist (default is YES) (originally from an @alunny pull request)
Date Fri, 03 Feb 2012 01:07:26 GMT
Updated Branches:
  refs/heads/master f96e26929 -> 07485c14f


Added UIWebViewBounce key to PhoneGap.plist (default is YES) (originally from an @alunny pull
request)


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/07485c14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/07485c14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/07485c14

Branch: refs/heads/master
Commit: 07485c14fb72b45436e17640abe5c4fa8ef6be98
Parents: f96e269
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu Feb 2 17:07:02 2012 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu Feb 2 17:07:02 2012 -0800

----------------------------------------------------------------------
 PhoneGap-based Application/PhoneGap.plist |    2 ++
 PhoneGapLib/Classes/PGViewController.m    |   24 ++++++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/07485c14/PhoneGap-based
Application/PhoneGap.plist
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/PhoneGap.plist b/PhoneGap-based Application/PhoneGap.plist
index 5ffe25e..3aeb9c5 100644
--- a/PhoneGap-based Application/PhoneGap.plist	
+++ b/PhoneGap-based Application/PhoneGap.plist	
@@ -2,6 +2,8 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>UIWebViewBounce</key>
+	<true/>	
 	<key>TopActivityIndicator</key>
 	<string>gray</string>
 	<key>EnableLocation</key>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/07485c14/PhoneGapLib/Classes/PGViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.m b/PhoneGapLib/Classes/PGViewController.m
index a9d7b0a..db6688c 100644
--- a/PhoneGapLib/Classes/PGViewController.m
+++ b/PhoneGapLib/Classes/PGViewController.m
@@ -132,11 +132,11 @@
     
     ///////////////////
     
-    NSNumber* enableLocation       = [settings objectForKey:@"EnableLocation"];
-    NSString* enableViewportScale  = [settings objectForKey:@"EnableViewportScale"];
-    NSNumber* allowInlineMediaPlayback = [settings objectForKey:@"AllowInlineMediaPlayback"];
+    NSNumber* enableLocation       = [self.settings objectForKey:@"EnableLocation"];
+    NSString* enableViewportScale  = [self.settings objectForKey:@"EnableViewportScale"];
+    NSNumber* allowInlineMediaPlayback = [self.settings objectForKey:@"AllowInlineMediaPlayback"];
     BOOL mediaPlaybackRequiresUserAction = YES;  // default value
-    if ([settings objectForKey:@"MediaPlaybackRequiresUserAction"]) {
+    if ([self.settings objectForKey:@"MediaPlaybackRequiresUserAction"]) {
         mediaPlaybackRequiresUserAction = [(NSNumber*)[settings objectForKey:@"MediaPlaybackRequiresUserAction"]
boolValue];
     }
     
@@ -160,6 +160,22 @@
         self.webView.mediaPlaybackRequiresUserAction = NO;
     }
     
+    // UIWebViewBounce property - defaults to true
+    NSNumber* bouncePreference = [self.settings objectForKey:@"UIWebViewBounce"];
+    BOOL bounceAllowed = (bouncePreference==nil || [bouncePreference boolValue]); 
+    
+    // prevent webView from bouncing
+    // based on UIWebViewBounce key in PhoneGap.plist
+    if (!bounceAllowed) {
+        if ([ self.webView respondsToSelector:@selector(scrollView) ]) {
+            ((UIScrollView *) [self.webView scrollView]).bounces = NO;
+        } else {
+            for (id subview in self.webView.subviews)
+                if ([[subview class] isSubclassOfClass: [UIScrollView class]])
+                    ((UIScrollView *)subview).bounces = NO;
+        }
+    }
+    
     ///////////////////
     
     if (!loadErr) {


Mime
View raw message