Almas Adilbek
Almas Adilbek

Reputation: 4410

What is the best solution to show NEWS html body using Objective-C?

I'm building news app. I need to beautifully show the body of news in separate page. The body may contain bold, italic, images, links, paragraphs etc, the all kind of html tags occurred in article body.

Years before I would use RTLabel but it's not supported anymore. I wouldn't mess with old libraries.

I thought about UIWebView, but I need something more native and easy to customize. What you think?

What about TTTAttributedLabel, is it the right choice I should consider?

Upvotes: 0

Views: 86

Answers (1)

Saheb Roy
Saheb Roy

Reputation: 5967

Use WKWebview for your purpose and it would serve you well. As far as the customizing the WKWebview in between view and stretching it for its full content, YES you can do that as well,as long as the WKWebview content is a whole and you dont want a view in between the webview content.

Here's what you got to do --

  1. Put a scrollview as the parent view.
  2. Put some view as the subview of the scrollview.
  3. Next create the WKWebview right after the content of the view, so that the WKWebview's y would start right after the y axis of the view.

Here is the tricky part.

  1. Calculate the WKWebview content height and update the frame to that of the content height.

You can do this by printing webView.scrollView.contentSize.height in this delegate method of the WKWebview--didFinishNavigation

  1. Put other views below the new updated WKWebview y axis.

Hope this helps

Upvotes: 1

Related Questions