Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在Objective-C中使用脱机HTML文件而不是URL_Iphone_Html_Objective C_Ios_Uiwebview - Fatal编程技术网

Iphone 在Objective-C中使用脱机HTML文件而不是URL

Iphone 在Objective-C中使用脱机HTML文件而不是URL,iphone,html,objective-c,ios,uiwebview,Iphone,Html,Objective C,Ios,Uiwebview,如何转换此代码,使其使用脱机捆绑文件而不是http://5times9.com? 所谓脱机文件,我假定您指的是您将预先放入捆绑包中的文件。在这种情况下,所有内容都在此处明确说明: 幸运的您:您的问题通过以下方式得到解决: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"offline5times9.com" ofType:@"htm"]; NSData *htmlData = [NSData dataWithCont

如何转换此代码,使其使用脱机捆绑文件而不是http://5times9.com?


所谓脱机文件,我假定您指的是您将预先放入捆绑包中的文件。在这种情况下,所有内容都在此处明确说明:

幸运的您:您的问题通过以下方式得到解决:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"offline5times9.com" ofType:@"htm"];  
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];  
if (htmlData) {  
    [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"http://kheldar.kikoo"]];  
} 

如果您想在某个时候从Internet更新HTML文件,您可以在文档中存储一个版本,如链接注释中所述。

这不是Xcode代码,而是Objective-C。您碰巧使用Xcode来管理它是无关紧要的。@Val:您能帮我吗?这在软件开发人员社区给您带来了很坏的声誉。你能为自己做的最好的事情就是仔细阅读以下内容:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"offline5times9.com" ofType:@"htm"];  
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];  
if (htmlData) {  
    [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"http://kheldar.kikoo"]];  
}