Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView responding while being scrolled?

I have a UICollectionView filled with some cells, and i implemented the method - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath This works like a charm, but it doesn't work while it is scrolling. It is a problem since the scrolling is very sensitive, and thus when i mean to push a cell and call the method, i end up scrolling with no result.

So i was wondering how to counter this and came up with this:

  • Can i simply set the method to respond while it is scrolling?
  • If not - Can i simply make it so scrolling ONLY happens if you use for example 2 fingers? to seperate the 2 actions more.

Thanks on advance

like image 528
Seerex Avatar asked Mar 19 '13 16:03

Seerex


1 Answers

The selection of a UICollectionViewCell happens when you tap it. A tap should be short and at one place. If you scroll instead, you're probably not tapping right. If this is the case, it would also happen while using built-in apps like Mail.

The UICollectionView uses a UITapGestureRecognizer to recognize selection of cells. This gesture recognizer doesn't allow specifics settings that might help you out in this case.

You might be able to change the UIPanGestureRecognizer to need 2 fingers, but you should really think about if that's what you want. You'd better use it the way Apple means it to be used, users are used to that.

That said, here's the documentation page on collection view's gesture support: http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/IncorporatingGestureSupport/IncorporatingGestureSupport.html

You might be able to use this to change the minimumNumberOfTouches property of the internally used UIPanGestureRecognizer. But again, I don't think you should.

like image 122
Guido Hendriks Avatar answered Sep 20 '22 17:09

Guido Hendriks