views:

313

answers:

1

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 ?

+3  A: 

You can add a very tiny UIScrollView in the window. Then tapping the status bar won't scroll the web view to top.

KennyTM
sugar