Visually Rich Links Tutorial for iOS: Image Thumbnails

Generate visually rich links from the URL of a webpage. In this tutorial, you’ll transform Open Graph metadata into image thumbnail previews for an iOS app. By Lea Marolt Sonnenschein.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 5 of 5 of this article. Click here to view the first page.

Using UIStackView Versus UITableView

You're using UIStackView to show these link previews instead of UITableView. Table views seem like the obvious choice to display data in a list but they're not the way to go with link presentations. There are two big reasons for this:

Memory issues in a table view.

  1. Sizing: If you follow Apple's advice and call sizeToFit() on the link preview in tableView(_:cellForRowAt:), you'll find the previews don't appear. You could get them to appear with Auto Layout constraints on your custom cell or by giving them a specific CGSize, but read on before you try this.
  2. Memory: Even if you can get your previews to appear, you have another issue: LPLinkViews in table views cause huge memory leaks. They can get as high as 10GB when scrolling! Take a look at the memory load below:

With a memory leak like that, your app will crash and the one-star reviews will start flying. Best to stay away from table views for link presentations!

Time to test your app one more time. Build and run and tap one of the links in the Saved tab. Safari will open and you'll see your chosen tutorial displayed as a web page. Good job!

Where to Go From Here?

Congrats! You've just learned most of what there is to know about link presentations!

Download the final project using the Download Materials button at the top or bottom of this page.

To learn more about what Apple has to say on the topic, watch the WWDC 2019 videos on Embedding and Sharing Visually Rich Links and Ensuring Beautiful Rich Links.

If you want to take a closer look at the framework, read the documentation on the LinkPresentation framework.

And if you're curious how to make links even more powerful and useful, check out our Universal Linking tutorial!

If you have any questions or comments, please join the forum discussion below.