当 LynnBubbleTableView 框架中的内容增长时,如何移动到 tableview 的底部?

Posted

技术标签:

【中文标题】当 LynnBubbleTableView 框架中的内容增长时,如何移动到 tableview 的底部?【英文标题】:how to move to bottom of tableview each time when content grows in LynnBubbleTableView framework? 【发布时间】:2018-07-12 06:58:05 【问题描述】:

我正在使用this chat layout from github。因为我正面临这个滚动问题。当 tableview 中的内容增长时,新内容必须自动可见,而无需用户滚动。我不知道如何修复这个框架中的这个错误。

【问题讨论】:

虽然看起来很宽泛,但从逻辑上讲,这可能就是您要寻找的内容:***.com/questions/33705371/… UITableView , Scroll to bottom on reload?的可能重复 我检查了上述所有问题,但是当我添加它时,我的应用程序会收到 SIGABRT 信号并在我添加到底部的行处崩溃。 这里的tableview不是uitableview类型。它是 Lynnbubbletableview 类型。如何解决? 【参考方案1】:

我浏览了您的库。请添加这行代码以滚动到最后一个位置。

self.tbBubbleDemo.reloadData() 之后:

 let lastSectionIndex = self.tbBubbleDemo!.numberOfSections - 1

    // Then grab the number of rows in the last section
    let lastRowIndex = self.tbBubbleDemo!.numberOfRows(inSection: lastSectionIndex) - 1

    // Now just construct the index path
    let pathToLastRow = IndexPath(row: lastRowIndex, section: lastSectionIndex)

    // Make the last row visible
    self.tbBubbleDemo?.scrollToRow(at: pathToLastRow as IndexPath, at: UITableViewScrollPosition.none, animated: true)

【讨论】:

我试过了,但调用了 SIGABRT,我的应用程序在“self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)”行崩溃 这里的tableview不是uitableview类型。它是 Lynnbubbletableview 类型。如何将此补丁添加到我的代码中?

以上是关于当 LynnBubbleTableView 框架中的内容增长时,如何移动到 tableview 的底部?的主要内容,如果未能解决你的问题,请参考以下文章