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];

 

你可能感兴趣的:(Apple)