ios - 显示 Tableview 的最后一个单元格

标签 ios swift uitableview

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

我已经在 viewDidLoad 中尝试过这个函数,但它无法在顶部单元格加载页面

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

最佳答案

尝试使用这个

DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [tableView] in
            if myArray.count > 0 {
               tableView.scrollToRow(at: IndexPath(item:myArray.count - 1 , section: 0), at: .bottom, animated: false)
            }
        }

关于ios - 显示 Tableview 的最后一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55456625/

相关文章:

ios - 错误域=NSPOSIXErrorDomain 代码=100 "Protocol error"

ios - 更改 Xcode 中不同按钮标签上的按钮图像

ios - 将框架添加到 Swift 项目

swift - iOS : Relation between firestore authentication and database

ios - Uitableviewcell 具有自定义 View ,在应用程序运行时无法正确调整大小(下图)

uitableview - 选择 `Color Blended Layers`时,UILabel被标记为红色

iphone - 需要 UILocalNotifications 的任何示例

swift - 打电话

ios - 将测试从一个单元测试目标导入到另一个

swift - 单击 UILabel 中的关键字