[IOS]HTML格式的UIWebView展示
2014-09-11 15:59
162 查看
[IOS]HTML格式的UIWebView展示
图例:游戏规则
#import "NVParentViewController.h" @interface SZGameRules : NVParentViewController @property (retain, nonatomic) IBOutlet UIWebView *gameRulesWV;//游戏规则WebViw @property (retain, nonatomic) NSString *gamerule; //游戏规则HTML路径 //知道了 - (IBAction)knowThe:(id)sender; @end #import "SZGameRules.h" @interface SZGameRules ()<UIScrollViewDelegate> @end @implementation SZGameRules - (void)viewDidLoad { [super viewDidLoad]; //清空webView上面内容 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]; [_infoWeb loadRequest:request]; [self cGameRules:_gamerule]; } //HTML -(void)cGameRules:(NSString *)gameRuleStr{ NSURL *url =[NSURL URLWithString:gameRuleStr]; NSURLRequest *request =[NSURLRequest requestWithURL:url]; [_gameRulesWV loadRequest:request]; [_gameRulesWV setFrame:CGRectMake(_gameRulesWV.frame.origin.x, _gameRulesWV.frame.origin.y, 244, 233)]; [_gameRulesWV setScalesPageToFit:YES]; //隐藏滚动条 _gameRulesWV.backgroundColor=[UIColor clearColor]; _gameRulesWV.opaque = NO; //透明,=YES时默认为白色背景 for (UIView *aView in [_gameRulesWV subviews]){ [aView setBackgroundColor:[UIColor clearColor]]; if ([aView isKindOfClass:[UIScrollView class]]){ UIScrollView *tempSV = (UIScrollView *)aView; tempSV.delegate = self; tempSV.tag = 1321; [tempSV setShowsHorizontalScrollIndicator:NO]; //滚动条不显示 [tempSV setShowsVerticalScrollIndicator:NO]; [tempSV setBounces:YES]; [tempSV setContentSize:CGSizeMake(1,tempSV.contentSize.height )]; for (UIView *shadowView in tempSV.subviews){ if ([shadowView isKindOfClass:[UIImageView class]]){ shadowView.hidden = YES; //拖拽后的上下阴影 } } } } } //知道了 - (IBAction)knowThe:(id)sender { [self.view removeFromSuperview]; } //避免UIWebView能左右拖动 #pragma mark UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if(scrollView.tag == 1321){ CGPoint tempPoint = scrollView.contentOffset; tempPoint.x = 0; [scrollView setContentOffset:tempPoint]; } }
图例:游戏规则
相关文章推荐
- 总结关于iPhone中UIWEBVIEW读取本地GBK编码格式html
- 总结关于iPhone中UIWEBVIEW读取本地GBK编码格式html
- ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容
- IOS UIWebView截获html并修改便签内容,宽度自适应
- ios UIWebView调用本地html和javascript,并且和ios通讯
- iOS UIWebView截获HTML并修改标签内容
- [ios]iphone 获取UIWebView内Html方法
- IOS UIWebView截获html并修改便签内容,宽度自适应
- UIWebView加载本地html ios
- iOS: UIWebview loadhtmlstring & Local css/js/image resources
- IOS开发之——UIWebView截获html并修改便签内容
- 转载 :ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容(转载)
- IOS开发之路二十一(UIWebView加载本地html)
- iPhone 和 iPad的ios 开发中 利用 WebViewJavascriptBridge组件,通过 UIWebView 对Html进行双向通讯
- iOS开发UIWebView展示网页实例代码
- ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容
- ios UIWebView截获html并修改便签内容以及用js对图片进行缩放