Stop scrolling to top in UIWebView - iPhone

Posted by sagar on Stack Overflow See other posts from Stack Overflow or by sagar
Published on 2010-05-21T06:12:14Z Indexed on 2010/05/21 6:20 UTC
Read the original article Hit count: 349

Filed under:
|
|
|
|

I have placed following javascript in my html file.

<script TYPE="text/javascript">
    function srk(){
        document.ontouchmove = function(e){ 
            e.preventDefault(); 
        }
    }
</script>

I am scrolling my webview by following code with some animation.

[myWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat: @"window.scrollTo(0,%i);",414*self.initialScrollPosition]];

Everything going right, but on problem that I am facing is as follows.

Whenever User/I tap on the status bar of iPhone, WebView Bydefault scrolls to top. This should not be done.

Is it possible to prevent inbuilt functionality ?

I know one of the option is as follows.

((UIScrollView *)[[myWebView valueForKey:@"_internal"] valueForKey:@"scroller"]).scrollsToTop = NO;

But is it valid to do ?

© Stack Overflow or respective owner

Related posts about uiwebview

Related posts about xcode