1
votes

i am adding UIWebview in tableview for showing text and link , but not able to scroll tableview, Any way to disable user interaction in webview only click event enable.

Webview have static content not load from web

NSString * htmlString = [NSString stringWithFormat:@"<html><head><script> document.ontouchmove = function(event) { if (document.body.scrollHeight == document.body.clientHeight) event.preventDefault(); } </script><style type='text/css'>* { margin:0; padding:0;} p { color:white; font-family:HelveticaNeue-CondensedBold; font-size:24px;} a { color:#63B604; text-decoration:underline; }</style></head><body><p>%@</p></body></html>", @"search in http://google.com"];

Thanks

3
[webview.scrollView setScrollEnabled:NO];TheTiger

3 Answers

0
votes

just disable scrolling or using this methods

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    // Disable user selection
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
    // Disable callout
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
}

and open link as follow using delagate methods

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if ( inType == UIWebViewNavigationTypeLinkClicked ) {
        NSURL *url = [inRequest URL];
        if ([[url absoluteString] rangeOfString:@"gmail"].location == NSNotFound) {
            [[UIApplication sharedApplication] openURL:[inRequest URL]];
            return NO;
        }
    }
    return YES;
}
-1
votes

Try to disable scrolling in your WebView

[myWebView.scrollView setScrollEnabled:NO]; 
[myWebView.scrollView setBounces:NO];