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)
}
}
}
我收到一个错误,其中说Argument labels'(forRow:,forSection :)不匹配任何可用的重载,有什么帮助吗?
答案 0 :(得分:3)
在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的自动完成功能。当然,如果您复制并粘贴旧代码,那么这无济于事。