Displaying HTML in iPhone app

2019-05-23 02:11发布

How to open url in textview iphone??

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

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-05-23 03:07

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

查看更多
家丑人穷心不美
3楼-- · 2019-05-23 03:14

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>
查看更多
登录 后发表回答