簡體   English   中英

NSURLCache不支持file://?

[英]NSURLCache don't support file://?

我想在UIWebView使用NSURLCache加載[NSURL fileURLWithPath:@"2.html"] ,執行cachedResponseForRequest:函數並返回一個在http://方案中正確執行的NSCachedURLResponse對象。
但是, UIWebView加載最終失敗。 我錯過了一些可選的嗎?

我想在壓縮文件中使用UIWebView加載html文件,並且我不希望將文件解壓縮到磁盤。 有什么建議嗎?

做這個:

 NSURL *url = [[NSBundle mainBundle] URLForResource:@"2" withExtension:@"html"];
 NSString *html = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
 NSURL *baseUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
 [webView loadHTMLString:html baseURL:baseUrl];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM