设为首页 加入收藏

TOP

UIWebView加载本地html文件
2017-10-13 10:33:09 】 浏览:4253
Tags:UIWebView 加载 本地 html 文件
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-64)];
        webView.backgroundColor=YYCToothWashViewBgColor;
        [self.view addSubview:webView];

    
    //加载本地html文件
    NSString *path = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];
    
    //protocal   html文件名称    html文件类型
    NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"protocal"
                                                          ofType:@"html"];
    NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
                                                    encoding:NSUTF8StringEncoding
                                                       error:nil];
    [webView loadHTMLString:htmlCont baseURL:baseURL];
View Code

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇在Objective-C声明Block的几种方式 下一篇iOS进阶学习-多线程

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目