简体   繁体   English

UICollectionView拦截触摸

[英]UICollectionView intercepting touches

I have a UICollectionView with a custom layout and in my view controller I do: 我有一个具有自定义布局的UICollectionView,并且在我的视图控制器中:

[self.collectionView setMultipleTouchEnabled:YES];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"TOUCHED");
}

but that method never gets called. 但是这种方法永远不会被调用。 I was previously using a tableviewcontroller in conjunction with a navigation controller and I set multiple touch enabled on the nav controllers view and all was good but now I switched the tableview out with the collection view and touches are never captured. 我以前将tableviewcontroller与导航控制器结合使用,并且在nav controllers视图上启用了多点触摸,一切都很好,但是现在我将Tableview与集合视图切换了出去,并且从未捕获任何触摸。

You could use UIGestureRecoginzer to intercept a gesture. 您可以使用UIGestureRecoginzer截取手势。 It also has to have multiple touch enabled, but it gets more specific to what touch you want to capture. 它还必须启用多点触摸,但是它更具体地取决于您要捕获的触摸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM