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的方法了,就是这两个方法你只能选一个,目前博主还没有找到两个方法都能进去的方法。
- (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的方法了,就是这两个方法你只能选一个,目前博主还没有找到两个方法都能进去的方法。
相关文章推荐
- 01【iOS总结】UIView、UILabel、UITextField、UIButton 、目标动作机制(+UIAlertView、UIAlertController)
- easyui combobox 省市区三级联动
- FM ENQUEUE_E_TABLE DEQUEUE_E_TABLE
- Item 18: 使用srd::unique_ptr来管理独占所有权的资源
- A review of 3D/2D registration methods for image-guided interventions(2)
- ios SDK 版本造成的UI混乱
- UITextView 实现 placeholder
- Android开源之仿微信UI
- UICollectionView分组-组头处理
- java修改request的paramMap
- UIPageControl页面控制的控件
- 随意细解:UI -- MVC、通知
- css:Media Queries
- 控制Arduino的利器-Windows Remote Arduino
- uinavigationcontroller手势返回
- [转!]jQuey中的return false作用是什么
- iOS 一行代码去掉UITableview多余分割线
- 基于easyui的CMS系统的小结
- nutz 结合QueryResult,Record 自定义分页查询,不构建pojo 整合
- 在T-SQL语句中访问远程数据库(openrowset/opendatasource/openquery)