[cc lang=”c++”]
- (void)loadDocument:(NSString)docName {
NSArray paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//NSString documentsDirectory = [paths objectAtIndex:0]; 该方法为从Documnent中加载
//NSString path = [documentsDirectory stringByAppendingPathComponent:docName];
NSString mainBundleDirectory = [[NSBundle mainBundle] bundlePath];//该方法为把html文件添加到App内部
NSString path = [mainBundleDirectory stringByAppendingPathComponent:docName];
NSURL url = [NSURL fileURLWithPath:path];
NSURLRequest request = [NSURLRequest requestWithURL:url];
self.myWebView.scalesPageToFit = YES;
[self.myWebView loadRequest:request];
}
[/cc]