有没有什么方法可以在运行时在iphone中编辑html文件?
大家好 是否有任何方法可以编辑资源目录中的html文件,我们希望先编辑该html中的一些标记,然后在web视图中显示该html 有可能吗 谢谢…是的 1) 找到并加载文件 2) 进行编辑 3) 保存文件 不过,您必须刷新webview才能使更改生效有没有什么方法可以在运行时在iphone中编辑html文件?,iphone,Iphone,大家好 是否有任何方法可以编辑资源目录中的html文件,我们希望先编辑该html中的一些标记,然后在web视图中显示该html 有可能吗 谢谢…是的 1) 找到并加载文件 2) 进行编辑 3) 保存文件 不过,您必须刷新webview才能使更改生效 NSBundle *bundle = [NSBundle bundleForClass:[self Class]]; NSString *htmlPath = [bundle pathForResource:@"html file name" ofT
NSBundle *bundle = [NSBundle bundleForClass:[self Class]];
NSString *htmlPath = [bundle pathForResource:@"html file name" ofType:@"htm"];
NSString *htmlContent = [NSString stringWithContentOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
// Do your HTML edits here
[[self webView] loadHTMLString:htmlContent baseURL:nil];
这假设您拥有视图控制器的webview
属性。另外,我不知道本地文件的baseURL应该是什么。我知道我以前做过,但我现在没有权限访问这些文件。希望这能让你走到这一步