【问题标题】:MSMessagesAppViewController messes up UITableViewController scrollingMSMessagesAppViewController 搞砸 UITableViewController 滚动
【发布时间】:2018-03-11 18:39:35
【问题描述】:

当我的 MSMessagesAppViewController 将 PresentationStyle 从 compact 更改为 expanded 并返回到 compact 时,我的 UITableView 的滚动变得一团糟。

我正在使用 AutoLayout 在名为 contentView 的视图中设置 UITableView

// 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 不变

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

提前致谢!

【问题讨论】:

  • 我刚刚注意到,Dropbox 在他们的 iMessage 应用程序中的 tableView 存在完全相同的问题!似乎是一个iOS错误。我将打开一个错误报告

标签: ios swift uitableview imessage-extension


【解决方案1】:

尝试使用UIViewControllerUITableView,而不是使用UITableViewController

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

【讨论】:

    猜你喜欢
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-02
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    相关资源
    最近更新 更多