1
votes

When my MSMessagesAppViewController changes the presentationStyle from compact to expanded and back to compact, my UITableView is messed up regarding its scrolling.

I am using AutoLayout to setup a UITableView inside of a View called contentView.

// Inside MSMessagesAppViewController
func createTableView() {
    let tableViewController = MyTableViewController()
    self.addChildViewController(tableViewController)

    tableViewController.tableView.backgroundColor = UIColor.clear
    tableViewController.tableView.translatesAutoresizingMaskIntoConstraints = false

    self.contentView.addSubview(tableViewController.tableView)

    NSLayoutConstraint.activate([
        tableViewController.tableView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 0),
        tableViewController.tableView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 0),
        tableViewController.tableView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: 0),
        tableViewController.tableView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 0)
        ])
}

After expanding and collapsing the MSMessagesAppViewController, I can suddenly scroll past my last cell in the tableView...

Everything is working perfectly fine in the initial state. I noticed, that the scrollbar is visible on startup, but is not present after the size change...

This is how I setup my tableView in the controller:

// Inside MyTableViewController
func setupTableView() {
    tableView.dataSource = self
    tableView.register(QuickStandardTableViewCell.self, forCellReuseIdentifier: "standardCell")

    tableView.rowHeight = UITableViewAutomaticDimension
    tableView.estimatedRowHeight = 64

    tableView.translatesAutoresizingMaskIntoConstraints = false
    tableView.separatorColor = .clear

    tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
    tableView.estimatedSectionHeaderHeight = 8.0

    self.extendedLayoutIncludesOpaqueBars = false 
}

What I checked:

  • The contentView frame changes correctly
  • The tableView frame changes correctly
  • The contentInset does not change
  • The contentSize does not change

Does anybody know what I am missing?

On Startup

Afterwards

Thanks in advance!

1
I just noticed, that Dropbox has the exact same issue with their tableView in their iMessage app! Seems to be an iOS bug. I‘ll be opening up a bug reportMikeB

1 Answers

0
votes

Try using a UIViewController with a UITableView inside instead of using UITableViewController.

I had the same problem with an UICollectionViewController and switching to UIViewController solved this problem.