I am developing appleTV application.
I have a UICollectionView inside a UICollectionView cell.
When the data is updated, the CollectionView placed in the ViewController is reloadData, and at the same time, the CollectionView in the CollectionView is also reloadData.
Then focus does not return to the original position in CollectionView.
The CollectionView placed in the ViewController is canFocusItemAt false.
What should I do?
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if collectionView === self.collectionView {
return 10
} else {
return 10
}
}
func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool {
if collectionView === self.collectionView {
return false
} else {
return true
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView === self.collectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "aaaa", for: indexPath)
if let collectionView = cell.viewWithTag(20) as? UICollectionView {
collectionView.delegate = self
collectionView.dataSource = self
collectionView.reloadData()
}
return cell
} else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "bbbb", for: indexPath)
return cell
}
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.collectionView.reloadData()
}