重写touchBegin 方法是不行的,在UITableView/UIScrollView 解决方案 重写hitTest:withEvent:  在他们的子类中 - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { static UIEvent *e = nil; if (e != nil && e == event) { e = nil; return [super hitTest:point withEvent:…
在使用了 UITableView 或UIScrollView的controller 里无法响应触摸事件touch事件, 自定义tableView.scrollView #import <UIKit/UIKit.h> @interface touchScrollView : UIScrollView @end #import "touchScrollView.h" @implementation touchScrollView - (id)initWithFrame:(CGR…
原因是:UIView的touch事件被UIScrollView捕获了. 解决办法:让UIScrollView将事件传递过去.于是最简单的解决办法就是加一个UIScrollView的category.这样每个用到UIScrollView的地方只要导入这个category就可以直接响应相关的touch事件了. 类似问题:在论坛看见很多人说UIImageView也没办法响应,不过我想解决办法和原因都是一样的. #import "UIScrollView+UITouch.h" @impleme…
UIScrollView本身事是不支持touch的,我们可以给她添加拓展 #import "UIScrollView+util.h" @implementation UIScrollView (util) -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ [[self nextResponder] touchesBegan:touches withEvent:event];…
1. 1:@property MyScrollView *scrollView; 2:给MyScrollView,增加类别:MyScrollView+Touch 3:在类别里实现下面三个方法: @implementation MyScrollView (Touch)- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {[[self nextResponder] touchesBegan:touches withEven…
要理解这两个方法.先了解一下用户触摸屏幕后的事件传递过程. 当用户点击屏幕后,UIApplication 先响应事件,然后传递给UIWindow.如果window可以响应.就开始遍历window的subviews.遍历的过程中,如果第一个遍历的view1可以响应,那就遍历这个view1的subviews(依次这样不停地查找,直至查找到合适的响应事件view).如果view1不可以响应,那就开始对view2进行判断和子视图的遍历.依次类推view3,view4……  如果最后没有找到合适的响应vi…
*当用户点击屏幕时,会产生一个触摸事件,系统会将触摸事件加入到 UIApplication管理事件队里中 *UIApplication 会从事件队列中取出最前面的事件进行分发以便处理,通常,先发送事件给应用程序主窗口(UIwindow0 *主窗口会调用 hitTest:withEvent:方法在视图(UIView)层次结构中找到一个最合适的 UIView来处理触摸事件 (hitTest:LwithEvent:其实是 UIView 的一个方法UIWindow 继承自 UIView,因此主窗口UIW…
此方法可实现点击穿透.点击下层视图功能 一. hitTest:withEvent:调用过程 iOS系统检测到手指触摸(Touch)操作时会将其放入当前活动Application的事件队列,UIApplication会 从事件队列中取出触摸事件并传递给key window(当前接收用户事件的窗口)处理,window对象首先会使用hitTest:withEvent:方法寻找此次Touch操作初始点所在的 视图(View),即需要将触摸事件传递给其处理的视图,称之为hit-test view. win…
整理来自互联网- 这是tableView继承的scrollView的一个属性 scrollsToTop. 官方说明是这样的: // When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its del…
现在的uitableview 的上面  响应不了     touchesbegan 事件   可能算是苹果的一个bug吧,不知道以后会不会改变 今天试了好久  都不行  最后  写了个字类  继承自  tableview 结果  可以响应事件了, 但是  上面的cell  也跟着响应这个事件, 真是坑爹啊…