ios - 如何在iOS中将内容添加到html文件

标签 ios iphone ios7 uiwebview

我想向项目资源中可用的html文件添加内容。
例如:-下面是html,里面有一些标签

<body >
<div id="abc">
    <div>{feed}<br /></div>
    <div >{date}</div>
</div>
</body>

我想用其中的一些字符串替换{feed},{date}并在UIwebview中显示该html
请给我一些指导以实现它
提前致谢

最佳答案

//Get your HTML file path.
NSString * htmlFilePath = [[NSBundle mainBundle] pathForResource:@"YOUR_FILE_NAME" ofType:@"html"];

//get the file content to a NSString.
NSString *htmlContentString = [NSString stringWithContentsOfFile:htmlFilePath encoding:NSUTF8StringEncoding error:nil];

// Then you need to replace a string (say 'stringA') with new string (say 'stringB')
    htmlContentString = [htmlContentString stringByReplacingOccurrencesOfString:stringA withString:stringB];

//Then load the new HTML string to your webView

[yourWebView loadHTMLString:htmlContentString baseURL:nil];

关于ios - 如何在iOS中将内容添加到html文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21930484/

相关文章:

ios - 从 SCNScene url 获取下载进度

ios - 从模态返回时视频播放器未加载

IOS:如何在循环内使用 UIAlertView

ios - AFNetworking iOS 添加 curl

iphone - C 或 Objective C 中的数学问题

ios - 使用 Storyboard时 GIDSignInButton 未加载 Google Plus.bundle

ios - Swift 无法识别的选择器发送到实例 - 我缺少什么?

uikit - iOS 7 : What is UIBarButtonItem's default font?

ios - 如何访问下载的解压文件夹中的图像?

ios - 在ios中注销时删除cookie