您的位置:首页 > 产品设计 > UI/UE

UICollectionView不能实现touch方法

2015-12-17 17:28 453 查看
页面有UICollectionView,写了touch方法但就是进不去,找了好长时间终于解决了,就是写一个UICollectionView的分类,在.m中写入如下三个方法

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

[[self nextResponder] touchesBegan:touches withEvent:event];

[super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

[[self nextResponder] touchesMoved:touches withEvent:event];

[super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{

[[self nextResponder] touchesEnded:touches withEvent:event];

[super touchesEnded:touches withEvent:event];
}

并且用的UICollectionView的类中不用引用这个分类的头文件,这样就把问题解决了。

虽然这样就可以进入touch方法了,但有一个不好的是,进不去选中cell的方法了,把touch方法注释掉就能进入选中cell的方法了,就是这两个方法你只能选一个,目前博主还没有找到两个方法都能进去的方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: