I would like to scroll the UICollectionView to the bottom so the last item is in the view. I have tried to use scrollToItemAtIndexPath but it does not seem to be working. I want
Swift 4.2
let lastSection = self.messagesCollectionView.numberOfSections - 1
let lastRow = self.messagesCollectionView.numberOfItems(inSection: lastSection)
let indexPath = IndexPath(row: lastRow - 1, section: lastSection)
self.messagesCollectionView.scrollToItem(at: indexPath, at: UICollectionView.ScrollPosition.top, animated: true)