Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScrollView within UICollectionViewCell Not Working

I have a UICollectionView with a custom UICollectionViewCell. The UICollectionView scrolls horizontally, with each cell occupying all of the visible screen.

The UICollectionViewCell has a UIView subview, which in turn has a UIScrollView subview.

The UIScrollView is intended to scroll vertically, but it's not scrolling at all. I've tried setting the scroll view's contentSize with no success.

I suspect that the UIScrollView is not getting any touch events rather than it being a size issue.

Any suggestions?

EDIT >>

I'm now sure it's an event problem rather than anything specific to the UIScrollView.

I've now overridden the pointInside: method in the UIView in the UICollectionViewCell and can see that it now returns false every time I tap on it. In that case you'd think that the tap event would propagate to the next subview , but the UIView still isn't getting events. I've tried adding a UIGestureRecognizer to the UIView but it never registers a tap.

Could there be anything here intercepting the events that I'm not aware of?

like image 502
Phil John Avatar asked Feb 07 '13 14:02

Phil John


1 Answers

I've been trying to solve a similar problem with a scrollview, and your edit about events reminded me of this question (which solved my problem again) How can I use a UIButton in a UICollection supplementary view?

Its possible you need to be using a UICollectionReusableView, not a UICollectionViewCell. Changing the class worked for me because I was using a button (and recently a scrollview) in a header.

However I've not tried for cells themselves. For capturing events from a UICollectionViewCell, maybe the following may help? Getting button action : UICollectionView Cell

like image 78
JonLord Avatar answered Nov 15 '22 06:11

JonLord