Reputation: 13753
How can I display properly formatted text from an NSString, that just happens to be HTML. The html is coming from the stack overflow API.
Upvotes: 2
Views: 2424
Reputation: 96323
You could have a WebView, and tell the WebView's mainFrame
to load the HTML string.
If you meant to ask about Cocoa Touch, UIWebView has an equivalent method for you.
Upvotes: 0
Reputation: 31342
If your tags are accurate and you are programming for OS X (or iPhone 4.0+), you can use NSAttributedString's – initWithHTML:documentAttributes:, and then draw that directly.
Unfortunately, the iPhone OS' UIKit does not contain NSAttributedString pre-4.0. The current recommendation from the developer docs is to use a UIWebView, which sucks. An alternative might be the Three20 library, which contains TTStyledText -- that looks like it might do the job.
Upvotes: 1
Reputation: 138031
You can create a NSAttributedString from HTML. You then draw it as you would draw any other NSAttributedString.
Upvotes: 7