1.隐藏拖动出来的上下两黑色背景
for (UIView *subView in [myWeb subviews]) {
if ([subView isKindOfClass:[UIScrollView class]]) {
for (UIView *shadowView in [subView subviews]) {
if ([shadowView isKindOfClass:[UIImageView class]]) {
shadowView.hidden = YES;
}
}
}
}
2.禁止双击等手势NSString *unscrollStr = [NSString stringWithFormat:@"<meta name=\"viewport\" content=\"width=device-width, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5, user-scalable=no\"/>"];
3.字体大小等的设置
NSString *htmlStr = [NSString stringWithFormat:@"<html> \n"
"<head> %@\n"
"<style type=\"text/css\"> \n"
"body {font-family: \"%@\"; font-size: %f;}\n"
"</style> \n"
"</head> \n"
"<body></body> \n"
"</html>", unscrollStr,@"宋体", 30.0] ;
4.加载本地html代码或者本地HTML文件
[myWeb loadHTMLString:htmlStr baseURL:nil];
5.禁止网页中的超链接,添加delegate.再引用以下方法
//需要注意的是:如果是引用本地html。以下方法会屏蔽本地html的显示
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
return NO;//NO是禁止,YES是允许
}