如何在 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/