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
相關文章
相關標籤/搜索