Prevent UIWebView sliding off the screen (iPhone)
Question
I have a full screen UIWebView component on the screen with fixed size content, so no scrolling required. When I nudge the screen the content in moving up or down.
The same effect can one experience all over the iPhone when there is a scroll-enabled component.
I would like to prevent this happening in my application. Please shed some light...
Solution
There seems to be a javascript that prevents scrolling while keeping the ability to click on links:
document.onload = function(){
document.ontouchmove = function(e){ e.preventDefault(); }
};
I have not tested this and can't find any documentation. I consider it a hack.
OTHER TIPS
<script>
document.ontouchmove = function(event){
event.preventDefault();
}
</script>
is more correct :)
If you don't need links to work:
myUIWebView.userInteractionEnabled = NO;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow