Reputation: 17
i tried to do something like this.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([self pointInside:point withEvent:event]) {
return _scrollView;
}
return nil;
}
but i get an error like
error: Automatic Reference Counting Issue: Receiver type 'ViewController' for instance message does not declare a method with selector 'pointInside:withEvent:'
please help me,thanks
Upvotes: 1
Views: 2839
Reputation:
What are you trying to do with that code?
self
is a UIViewController
, but the pointInside:withEvent:
method is defined for UIView
s. Try changing it to:
if([self.view pointInside:point withEvent:event])
Based on the reference to _scrollView
though, it looks like you should be writing something like:
if([self.scrollView pointInside:point withEvent:event])
Since you return the scrollview if that test passes.
To go even one step further, though, the default behaviour for hitTest:withEvent:
should in fact return _scrollView
if it's a subview of self.view
. So you shouldn't even need to write that method unless you're specifically excluding some of the other subviews from touch events. In that case, use the self.scrollView
way.
Upvotes: 4