首页 > 解决方案 > 显示 Tableview 的最后一个单元格

问题描述

加载数据后,我想显示 Tableview 的底部单元格我不想每次都滚动到 Tableview 的底部以查看结果

我在 viewDidLoad 中尝试过这个功能,但它在顶部单元格的页面加载不起作用

if myArray.count > 0 {
               tableView.scrollToRow(at: IndexPath(item:myArray.count - 1 , section: 0), at: .bottom, animated: false)
            }

标签: iosswiftuitableview

解决方案


您可以利用scrollView的setContentOffset:animated:方法

这个答案应该可以帮助你:How to show last add cell on UITableview whileloading view or reloading tableview?


推荐阅读