touchesBegan not responding
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@" touches "); }
The above method is not calling in my apps. My application description is as under.
I have a Main开发者_运维知识库ViewController
which loads a ContentViewController
in it. ContentViewController
has a webview which loads a pdf file.
How to listen the tap of MainViewController's
View.
Regards.
I may be not 100% accurate here, but if you place -touchesBegan:withEvent:
in your view controller (or its main view) then you will get only those touches that have not been handled by some subviews in the view hierarchy. To intercept all touches you should use UIView subclass for your controller view and override hitTest:withEvent:
method in it:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
touchedView = [super hitTest:point withEvent:event];
NSSet* touches = [event allTouches];
// handle touches if you need
return touchedView;
}
For more information see Event delivery section in "Event handling guide" for iOS
精彩评论