Cheng Yang Chen
Cheng Yang Chen

Reputation: 81

Custom layout CollectionView can't scroll

I followed the book "Learning AVFoundation" to create a video editor, the sample code use custom collectionview layout to show video and music track. Everything works fine. However, I can't horizontally scroll my UICollectionView. I checked content size is fine, it will increase after I add a clip. TouchEnable also checked, but no idea what's wrong here... My screenshot is like this

Upvotes: 1

Views: 390

Answers (1)

Cheng Yang Chen
Cheng Yang Chen

Reputation: 81

Just answer my question here. I made a silly mistake. Didn't notice that my layout add a UIPanGestureRecognizer, it will take care pan direction instead, so the view can't scroll even content size is right. I think below code affect the scroll behavior. Just remove gesture first then another way to control drag and move cell behavior.

CGPoint location = [recognizer locationInView:self.collectionView]; CGPoint translation = [recognizer translationInView:self.collectionView]; self.panDirection = translation.x > 0 ? THPanDirectionRight : THPanDirectionLeft;

Upvotes: 1

Related Questions