我无法滚动到底部,我尝试了其他解决方案但没有成功。
我正在使用IGLiskit
这是错误:
尝试滚动到无效的索引路径
这是代码:
func initMessages() {
DataService.call.retrieveMessages(roomID: room.id ?? "") { (success, error, messages) in
if !success {
print("error", error!.localizedDescription)
} else {
guard let messages = messages else {return}
self.messages = messages
DispatchQueue.main.async {
self.adapter.performUpdates(animated: true, completion: nil)
let indexPath = IndexPath(item: self.messages.count - 1, section: 0)
self.collectionView.scrollToItem(at: indexPath, at: .bottom, animated: true)
}
}
}
}