很久沒遇到了 , 分享一下
出問題的地方 ,?(self ==> 一個(gè)view , 里面的btn有點(diǎn)擊事件)
UIWindow* window = [UIApplication sharedApplication].windows[0];
[window addSubview:self];
將一個(gè)view添加到window上 , 在點(diǎn)擊這個(gè)view(蒙板之類的)時(shí) , 卻在觸發(fā)其他view的點(diǎn)擊事件 , 不管是滑動(dòng)和點(diǎn)擊 , 都在觸發(fā)其他view??
那就只響應(yīng)我要的那個(gè)view好了 , 在繪制這個(gè)view的.m里重寫這個(gè)方法 , eg: XXView.m下實(shí)現(xiàn)
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
[super hitTest:point withEvent:event];
CGPoint btn_P = [self.updateBtn convertPoint:point fromView:self];
if ([self.gcBtn pointInside:btn_P withEvent:event]) { // 你懂得
return self.gcBtn;
}
return self;//(只針對(duì)self處理響應(yīng))
}
搞定