I'm trying to set a default item when the view is loaded this way:
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.delegate = self
self.collectionView.dataSource = self
self.collectionView.allowsSelection = true
self.collectionView.allowsMultipleSelection = true
}
I'm trying to select an item in the viewDidAppear method:
override func viewDidAppear(_ animated: Bool) {
DispatchQueue.main.async(execute: {
self.collectionView.selectItem(at: IndexPath(item: 0, section: 0), animated: true, scrollPosition: UICollectionViewScrollPosition.bottom)
})
}
But the didSelectItemAt method is not fired like I need.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
//some config
}
Am I forgetting something?