gpt4 book ai didi

ios - IOS 13 中的滚动问题

转载 作者:行者123 更新时间:2023-11-28 23:21:42 24 4
gpt4 key购买 nike

为了实现表格 View 的滚动到底部,我使用下面的代码。

extension UITableView {

func scrollToBottom(){
let indexPath = IndexPath(
row: self.numberOfRows(inSection: self.numberOfSections -1) - 1,
section: self.numberOfSections - 1)
self.scrollToRow(at: indexPath, at: .bottom, animated: true)
}
}

这对于版本低于 13 的所有设备都工作得很好,但在 ios 13 中它没有完全滚动到最后一个单元格,而是在最后一个单元格之间停止(距离底部大约 40 像素)。

我也尝试过其他方法

  1. 设置内容偏移量
  2. 将滚动设置为可见的矩形
  3. 延迟 1.0 秒

但所有这些都具有相同的行为,而不是完全滚动。

最佳答案

如果您因为具有不同高度的不同单元格而面临此问题,那么下面的代码可能适合您:

private func moveTableViewToBottom(indexPath: IndexPath) {
tableView.scrollToRow(at: indexPath, at: .bottom, animated: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: false)
}
}

关于ios - IOS 13 中的滚动问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59575110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com