Member-only story

Auto Height Controller inside a UITableViewCell

Jerry PM
7 min read1 day ago

Inside the UITableViewCell, there is a view controller, and within that controller, there is a PagingViewController from Parcement.

So, some time ago, I encountered a UI bug in the project I was working on.

The issue was how to make a ViewController containing a PagingViewController automatically adjust its height.

Before fixing it, the height was set to a static size. However, since the data changed depending on the selected page, some parts of the UI were getting cut off.

The first thing I did was create a simple UI to test the approach.

Step 1: Creating an Auto-Height View Controller

The first thing I did was create a View Controller inside a UITableViewCell.

Starting with creating the parent View Controller, which I named “MainViewController”. Inside this, I also added a custom UITableViewCell.

The first cell is “BasicTableViewCell”, which doesn’t contain anything important, so I generated random data for it. Now, for “ParchmentTableViewCell”.

import SnapKit
import UIKit

class MainViewController: UIViewController {
private let tableView = UITableView()

override func viewDidLoad() {
super.viewDidLoad()…

--

--

No responses yet