1. 程式人生 > >UIView不接受觸控事件的三種情況:

UIView不接受觸控事件的三種情況:

1.

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event

{

returnNO;

}  也不會接受任何事件(包括子檢視)

2. 

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

{

returnself;

}  事件不會傳遞到子檢視  但是可以通過一下的方式傳遞給響應者鏈

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

{

//可以先處理自己的事

    [[selfnextResponder] touchesEnded:touches withEvent:event];

}