Home Scroll to last message on collection view is not working properly
 I have a CollectionView that has an input accesory view at the bottom containing a text field and other elements. The app works like a messaging app: you write something and then you send it, at which point the message is added to the collection view. The problem is that, with the code I've implemented, the "auto scroll" stars working when there is a certain number of messages (items in the collection view), 16-18 is the amount of items you need to add before the auto-scroll stars to work. This is the code I've implemented so far: DispatchQueue.main.async { self.collectionView?.reloadData() self.inputTextField.text = "" if self.messages.count > 0 { let indexpath = IndexPath(item: self.messages.count - 1, section: 0) self.collectionView?.scrollToItem(at: indexpath, at: .bottom, animated: true) } }  That code is in the textFieldShouldReturn method. This is what i get when i put a breakpoint in the line "self.collectionView?..." Thanks in advanced for the help!!!