Im building a chat App with Firebase,and I have a problem is after reloadData() will scroll top.
How can I to disable that?
This my code
func retrieveDataFromFirebase(){
FIRDatabase.database().reference().child("share").child("post").observe(.value) { (snapshot:FIRDataSnapshot) in
if let snapshots = snapshot.children.allObjects as? [FIRDataSnapshot]{
self.key.removeAll()
self.users.removeAll()
for snap in snapshots{
self.key.append(snap.key)
if let dic = snap.value as? [String:AnyObject]{
let msg = Message()
msg.setValuesForKeys(dic)
self.users.append(msg)
}
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}