我在tableview中添加了UIWebview以显示文本和链接,但无法滚动tableview,任何在webview中禁用用户交互的方法都只是单击事件启用。
Webview的静态内容无法从网络加载
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"];
由于
答案 0 :(得分: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;
}
答案 1 :(得分:0)
答案 2 :(得分:-1)
尝试在WebView中禁用滚动
[myWebView.scrollView setScrollEnabled:NO];
[myWebView.scrollView setBounces:NO];