func scroller() {
let delay = 0.1 * Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
if self.chatMessages.count > 0 {
let lastRowIndexPath = IndexPath(forRow: self.chatMessages.count - 1, inSection: 0)
self.tblChat.scrollToRowAtIndexPath(lastRowIndexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: true)
}
}
}
我收到一个错误,它说参数标签'(forRow:, forSection:) 不匹配任何可用的重载,有什么帮助吗?
最佳答案
在 Swift 3 中你需要:
let lastRowIndexPath = IndexPath(row: self.chatMessages.count - 1, section: 0)
self.tblChat.scrollToRow(at: lastRowIndexPath at: .bottom animated: true)
您似乎在尝试使用较旧的 Swift 2 API。
查看 IndexPath
和 UITableView
的文档。并尝试在键入代码时使用 Xcode 的自动完成功能。当然,如果您复制并粘贴旧代码,那也无济于事。
关于ios - 使用 tableview 时 xcode 中的可用重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43879028/