I am trying to get some UIViews to register touch events. Per Apple's recommendation, I am overriding UIView's hitTest method. I am using this code, which I copied & pasted from Apple's documentation:
However, for some reason, Xcode says there's no targetView property. Am I using old code? If so, will someone please post either the right code or a link to it? Thanks!
Edit: I am using the iOS 8.4 SDK.
Code:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
// Convert the point to the target view's coordinate system.
// The target view isn't necessarily the immediate subview
CGPoint pointForTargetView = [self.targetView convertPoint:point fromView:self];
if (CGRectContainsPoint(self.targetView.bounds, pointForTargetView)) {
// The target view may have its view hierarchy,
// so call its hitTest method to return the right hit-test view
return [self.targetView hitTest:pointForTargetView withEvent:event];
}
return [super hitTest:point withEvent:event];
}
However, for some reason, Xcode says there's no targetView property. Am I using old code? If so, will someone please post either the right code or a link to it? Thanks!
Edit: I am using the iOS 8.4 SDK.