Displaying HTML in iPhone app

你说的曾经没有我的故事 提交于 2019-12-08 02:11:08

问题


How to open url in textview iphone??

Is it possible to show data with links,photos and all html entities???


回答1:


It's not possible with UITextView control. Use UIWebView or make your own custom control.




回答2:


You can use UIWebView to load a static contain from files; html, photo, 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];

then just add "index.html" as normal HTML standard to your project.

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


来源:https://stackoverflow.com/questions/5777992/displaying-html-in-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!