1

我在 tableview 中添加 UIWebview 以显示文本和链接,但无法滚动 tableview,在 webview 中禁用用户交互的任何方式都只能单击事件启用。

Webview 具有未从 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"];

谢谢

4

3 回答 3

0

我从网站 http://nickharris.wordpress.com/2010/06/17/fast-uitableviewcell-with-a-uiwebview/得到了答案

于 2013-08-07T08:07:29.527 回答
0

只是禁用滚动或使用此方法

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

并使用 delagate 方法打开如下链接

-(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;
}
于 2013-08-06T10:02:00.667 回答
-1

尝试在 WebView 中禁用滚动

[myWebView.scrollView setScrollEnabled:NO]; 
[myWebView.scrollView setBounces:NO];
于 2013-08-06T10:03:19.523 回答