美文网首页Collection view
collection view 2 - Incorporatin

collection view 2 - Incorporatin

作者: 轻云绿原 | 来源:发表于2017-03-25 15:52 被阅读5次

    来源:https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/IncorporatingGestureSupport/IncorporatingGestureSupport.html

    Incorporating Gesture Support

    重点:你应该对collection view加手势,而不是一个具体的cell或view.

    collectionview 对单点手势已经有delegate去监听了。所以,你只能加双击手势或其它非单击手势。

    下面的代码,展示了怎么让collection view 响应您的双击手势而不是响应delegate里的选择/高亮手势。

    UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];

    tapGesture.delaysTouchesBegan = YES;

    tapGesture.numberOfTapsRequired = 2;

    [self.collectionView addGestureRecognizer:tapGesture];

    你可以通过设置delaysTouchesBegancancelsTouchesInView属性 true,来让您的手势的优先级别高于默认选择监听者。当手势注册了,你首先会查看你的手势是否有优先级。只有当输入对你的手势无效时,那里delegate的方法才会像平时一样会调用。

    相关文章

      网友评论

        本文标题:collection view 2 - Incorporatin

        本文链接:https://www.haomeiwen.com/subject/wuscottx.html