简体   繁体   中英

UICollectionView's didSelectItemAtIndexPath method is called only once

I have UIView A . UIView A is loaded with UICollectionView . That is fine. In this situation, whenever I touch UICollectionView's cells , didSelectItemAtIndexPath is called.

Sometimes, there is a condition I need to load UIView B loaded onto UIView A . UIView B is loaded and once its process is completed UIView B is setHidden.

The problem is UIView B is loaded and setHidden, after that when I touch UICollectionView's cells , didSelectItemAtIndexPath is not called .

What is wrong with this problem?

Thanks

Please try this after your UIViewB loaded and setHidden

[viewA bringSubviewToFront:collectionView];

Guess this will work.

yes @Jaimish's suggestion is correct. I have UITapGestureRecognizer inside UIView B. Once UIView B is loaded, UICollectionView's TapGesture doesn't work.

Remove the UITapGestureRecognizer of View B when you hide that view and then When you show View B, again add UITapGestureRecognizer in View B.

It will work definitely.

When you hide view B.

[ViewB removeGestureRecognizer:YourTapGesture];

When you show view B.

[ViewB addGestureRecognizer:YourTapGesture];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM