转自:http://www.cocoachina.com/bbs/read.php?tid-21900.html
- (void)loadDocument:(NSString*)docName {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:docName];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
self.myWebView.scalesPageToFit = YES;
[self.myWebView loadRequest:request];
}
这个函数是加载Documents里边的文件,如果是你App内部的,需要改一下代码
NSString *mainBundleDirectory = [[NSBundle mainBundle] bundlePath];
NSString *path = [mainBundleDirectorystringByAppendingPathComponent:docName];