2011-06-15 89 views
2

我在我的xcode項目中有一個本地html文件。但我無法使用UIWebView加載該本地HTML文件。在UIWebview中加載本地html文件

+0

它可能是有用的,你快樂,請張貼一些代碼 – 2011-06-15 12:20:52

回答

9

的代碼來實現你的要求是:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 
self.view.frame.size.height,self.view.frame.size.width)]; 

NSString *indexPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:nil]; 
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:indexPath]]]; 
[self.view addSubview:webView];