【发布时间】:2014-01-23 06:12:48
【问题描述】:
我已经为 UICollectionView 中的 UIScrollView 设置了 UITapGestureRecognizer。我已将其配置为正确检测点击并触发我编写的方法,但如果我尝试将选择器设置为 collectionView:didSelectItemAtIndexPath: 当点击单元格时程序崩溃。
知道为什么会这样吗?
这行得通:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
- (void) tapped:(UIGestureRecognizer *)gesture{
//some code
}
这不起作用:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(collectionView:didSelectItemAtIndexPath:)];
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//some code
}
【问题讨论】:
标签: ios objective-c uiscrollview uicollectionview uitapgesturerecognizer