ahmedk92 / QandA

Ask free questions by opening an issue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Tappable Container View Steals Interaction From an Embedded Collection View

ahmedk92 opened this issue · comments

This is a common scenario where taps outside the collection are needed for something like hiding the keyboard or custom modal dismissal. However, in a setup where the tappable view is a superview (not necessarily a direct superview) of the collectionView (or any interacting view), that superview will steal all the touches.

Solution

Put the tappable view in different subtree than the rest of interacting views. To visualize:

Instead of:

rootView -> tappableView -> collectionView

It should be:

rootView -> tappableView
         -> collectionView

You can try a demo here.