当我的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
}
我检查了什么:
有人知道我错过了什么吗?
提前致谢!
答案 0 :(得分:0)
尝试使用内置UIViewController
的{{1}}而不是UITableView
。
UITableViewController
遇到了同样的问题,切换到UICollectionViewController
解决了这个问题。