tvOS UICollectionView's didSelectItemAtIndexPath not called

Hi guys,

there is a weird behaviour in ours tvOS app. There is an ordinary UICollectionView's grid of items.. everything seems correct, the focus seems right, but when I click on the remote, the didSelectItemAtIndexPath is not called. But when I place pressesBegan into cell's code, it is. So it seems the press is not delegated for some reason. Hard to say why it happens, I don't have any specific way how to brake it. Sometimes works, sometimes not.


Have you had similar issue? Anybody? Thanks..

Replies

The "didSelectRowAtIndexPath" method is triggered when a cell receives "pressesEnded". It's possible that, if you have a gesture recognizer attached to the cell or the collection view that's listening for the same Select button press, that the cell is actually receiving "pressesCancelled" instead (this is normal: when gestures recognize, the event is considered cancelled from the view's perspective, but continues normally from the gesture's perspective)

Thats interesting.. I've got pressesBegan evertime, but pressesEnded like 1 out of 7 only.. don't know why. I'm not using any own gesture recognizer. But I saw the UICollectionView has more then 7 in gestureRecognizers array.. It confuse me, why the pressesCanceled is triggered in my case. Keep digging, thank you for this particular answer, it helped me a lot to understand the key issue

maybe collectionView's delegate is not set?

Hey, I thinks there's something wrong with the UIResponder chain in tvOS10. try removing super.pressesBegan(presses, with: event) from pressesBegan. This should stop the tvOS from sending the press up the chain to the app delegate.

Hi,


We are struggling with a similar problem in our tvOS app. Everything seems working good until we show a view controller in a container view. There are gesture and UIPress delegate method implementations in this view controller. When we pop this view controller, all did select methods(table view, collection view) in the project are not called however focus and button action behaviours are working properly. Did you find a solution ?


Thanks.