UIWebView加载本地文件

 
NSString *htmlPath = @"addComment.html";
	NSString *encodedPath = [htmlPath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    NSString *urlStr = nil;
    if (self.itemId == 0) {
        urlStr = [NSString stringWithFormat:@"file://%@", encodedPath];
    }
    else {
        urlStr = [NSString stringWithFormat:@"file://%@?userId=%@", encodedPath, self.itemId];
    }
    NSURL *url = [NSURL URLWithString:urlStr];
    NSURLRequest *request= [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];

猜你喜欢

转载自shfzhzhr.iteye.com/blog/1808004