Objective c 在脱机情况下加载UiWebView本地HTML 我以前用这些代码加载本地html

Objective c 在脱机情况下加载UiWebView本地HTML 我以前用这些代码加载本地html,objective-c,uiwebview,Objective C,Uiwebview,NSString*indexPath=[NSBundle pathForResource:@“index”的类型:@“html”inDirectory:nil]; [mWebView loadRequest:[NSURLRequestRequestWithURL:[NSURL fileURLWithPath:indexPath]]; 这是我的控制器代码。您可以使用此代码。它起作用了 I'm trying to load local HTML file in offline situatio

NSString*indexPath=[NSBundle pathForResource:@“index”的类型:@“html”inDirectory:nil]; [mWebView loadRequest:[NSURLRequestRequestWithURL:[NSURL fileURLWithPath:indexPath]];



这是我的控制器代码。

您可以使用此代码。它起作用了

I'm trying to load local HTML file in offline situation. I found a code here;

http://stackoverflow.com/questions/4645414/how-can-i-load-a-local-html-file-into-the-uiwebview
I'm using Reachability.h of Apple and it is working but I cant load local html file.

希望这有帮助。:)

添加一些您尝试的代码
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"terms_en" ofType:@"html"];
webView.delegate=self;
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:htmlString baseURL:nil];