iphone - 在 iPhone 应用程序中显示 HTML

标签 iphone html objective-c uiwebview uitextview

如何在 iPhone 的 textview 中打开 url?

是否可以显示带有链接照片和所有html实体的数据???

最佳答案

您可以使用 UIWebView 从文件加载静态包含; html、照片、css、javascript。

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];

[self.webView loadHTMLString:htmlString baseURL:baseURL];

然后只需将“index.html”作为普通 HTML 标准添加到您的项目中即可。

<html>
   <head><title>Hello</title></head>
   <body>
      <img src="icon.png"/>
      <p>Test</p>
   </body>
</html>

关于iphone - 在 iPhone 应用程序中显示 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5777992/

相关文章:

ios - 在哪里以及如何__bridge

c - 如何将此 C 日历代码转换为 Objective-C 语法并使其与矩阵一起使用

iphone - UITableView 和 UILabel 重复

ios - flickr 无法解析 JSON

iphone - 使用撇号安全地将数据插入 SQLite 数据库

html - API,将承载 token 传递到GET HTTP URL

html - 是为较小的显示器缩放所有页面的正确解决方案吗?

iphone - 如何在 iPhone 中加载高质量的 .gif 图像

html - 自定义 CSS 破坏 Bootstrap 模式

ios - 哪个更快? for 循环或 isEqualToArray