2012-01-03 99 views
0

我加載內容從本地的HTML文件的WebView居住在資源文件夾下面的代碼網站沒有顯示在ipad

NSString *path1 = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]; 


NSString *html = [NSString stringWithContentsOfFile:path1 encoding:NSUTF8StringEncoding error:nil]; 
[self.webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]]]; 
+0

的NSString * HTML = [NSString的stringWithContentsOfFile:PATH1編碼:NSUTF8StringEncoding錯誤:NI 1]; [self.webView loadHTMLString:html baseURL:nil];嘗試這個 – 2012-01-03 06:15:12

回答

0

用於加載HTML文件,該文件是在資源文件夾從HTML文件加載數據

NSString *filePath=[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 
[webView loadData:[NSData dataWithContentsOfFile:filePath] MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:nil]; 
0

這可能有助於

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: 
                   [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]isDirectory:NO]]]; 
相關問題