MSMessagesAppViewController弄乱了UITableViewController滚动

时间:2018-03-11 18:39:36

标签: ios swift uitableview imessage-extension

当我的MSMessagesAppViewController将presentationStyle从compact更改为expanded并返回到compact时,我的UITableView会因其滚动而搞砸。

我正在使用AutoLayout在名为UITableView的视图中设置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)
        ])
}

扩展并折叠MSMessagesAppViewController后,我可以突然滚动到tableView中的最后一个单元格...

在初始状态下,一切都运转良好。我注意到,滚动条在启动时可见,但在尺寸更改后不存在...

这是我在控制器中设置tableView的方法:

// 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 
}

我检查了什么:

  • contentView框架正确更改
  • tableView框架正确更改
  • contentInset不会更改
  • contentSize不会更改

有人知道我错过了什么吗?

On Startup

Afterwards

提前致谢!

1 个答案:

答案 0 :(得分:0)

尝试使用内置UIViewController的{​​{1}}而不是UITableView

UITableViewController遇到了同样的问题,切换到UICollectionViewController解决了这个问题。

相关问题