Thursday, February 11, 2010

Formatting UITextView

There is no feature to format the text in UITextView

We can use the UIWebView to display the formatted text
The easy two methods are :

1. - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
2. - (void)loadRequest:(NSURLRequest *)request

use the html formatted text as input.
NSString *htmlText = @"<html><head><meta name=""viewport"" content=""width=320""/></head><body><h3>Header</h3><p>Just for testing n;</p></body</html>";
[webView loadHTMLString:htmlText baseURL:[NSURL URLWithString:@""]];

2. Or we can load a local html file
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];

No comments:

Post a Comment