Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-02-2009, 02:43 PM   #20 (permalink)
V42
Registered Member
 
Join Date: Dec 2009
Posts: 2
Default Scrolling fix for OS v2.2.1

Quote:
Originally Posted by V42 View Post
I just got a rejection email for this reason. In case it helps anyone else, I figured out a solution that works for my needs. This solution is based on the javascript approach described earlier in this thread by MrMidi. The difference is that it disables scrolling/rubberbanding only when the content can fit entirely within the web view. If the content is larger than will fit, scrolling & rubberbanding are allowed.

Code:
<html>
  <head>
    <script>
      document.ontouchmove = function(event) {
        if (document.body.scrollHeight == document.body.clientHeight) event.preventDefault();
      }
    </script>
  </head>
  <body>
    <p>No scrolling for you!</p>
  </body>
</html>
I ran into a small problem with this approach. Apparently, there is a difference in behavior with regards to the clientHeight attribute in different versions of the iPhone OS. The above code works fine in v3.0, but not in v2.2.1. For some reason, in v2.2.1, the clientHeight is always equal to the scrollHeight, so the code would prevent scrolling in all cases. I was able to fix this by using window.innerHeight instead of document.body.clientHeight.
V42 is offline   Reply With Quote
 

» Advertisements
» Online Users: 338
13 members and 325 guests
ADY, antonwilliams, dacapo, dcool, HemiMG, jakerocheleau, leahov, michelle, MozyMac, nobre84, smithdale87, thh022, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,721
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:20 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.