Nirav Jain
Nirav Jain

Reputation: 5107

Displaying HTML in iPhone app

How to open url in textview iphone??

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

Upvotes: 2

Views: 1514

Answers (2)

Alex Nazarov
Alex Nazarov

Reputation: 1218

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

Upvotes: 1

Jirapong
Jirapong

Reputation: 24256

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>

Upvotes: 2

Related Questions