This is sometimes the easiest answer. I had the same problem as @Schmidt, but I was disappointed that his answer was to use indexPathForItemAtPoint: as if indexPathForCell: was somehow broken and could not be used for its intended purpose.
Then I tried its solution and still had the same result: the index path returned to zero.
Solution: The viewView collection controller is not connected to the UICollectionView instance in the NIB (on the storyboard). After creating this missing connection, both methods (indexPathForCell: and indexPathForItemAtPoint) worked as expected.
I know that other developers sometimes encounter this problem, so pay attention to this as a reminder: the problem may not be in your code, in fact, but in the Builder interface, as in an unconnected outlet (or just a confused outlet connected with something that no longer exists).
source share