Ghost View over Collection View Cell

Kuang Lin
1 min readDec 30, 2019

--

One day, I want to add a button on a collectionView Cell.

But the Button is not responding to the tapping!!!

So I turn on the view hierarchy debugger, and saw a UIView is over the collection view, above all the other views including the button I want.

The reason why this is that the one who wrote it is using UIView as the root view of .xib file.

If we do this way, the system will generate a transparent “Content View” of collection view cell for you, and covers all your views!

If your collection view do not have any other action than select, you will not encounter any problems. But if you do, make sure you use the

Collection View Cell class as your root view in .xib file!

--

--

Kuang Lin
Kuang Lin

No responses yet