修改代码如下:
- (UIView *) _basicHitTest: (CGPoint) point withEvent: (UIEvent *) event
{
// STUPID STUPID RAT CREATURES
// ===========================
//
// Problem: we want to do a default hit-test without UIScrollView's processing getting in the way.
// UIScrollView implements _defaultHitTest:withEvent: for this, but we can't call that due to it
// being a private API.
// Instead, we have to manufacture a call to our super-super class here, grr
/*
Method method = class_getInstanceMethod( [UIView class], @selector(hitTest:withEvent:) );
IMP imp = method_getImplementation( method );
return ( (UIView *)imp(self, @selector(hitTest:withEvent:), point, event) ); // -[UIView hitTest:withEvent:]
*/
SEL hitSelector = @selector(hitTest:withEvent:);
NSMethodSignature * signature = [self methodSignatureForSelector:hitSelector];
NSInvocation * invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget: self];
[invocation setSelector:hitSelector];
[invocation setArgument:&point atIndex:2];
[invocation setArgument:&event atIndex:3];
[invocation invoke];
NSValue * ret_val = nil;
NSUInteger ret_size = [signature methodReturnLength];
if( ret_size > 0 ) {
void * ret_buffer = malloc( ret_size );
[invocation getReturnValue:ret_buffer];
ret_val = [NSValue valueWithBytes:ret_buffer
objCType:[signature methodReturnType]];
free(ret_buffer);
}
// Copy the value into our UIView object
UIView * returnedView = nil;
[ret_val getValue:&returnedView];
return returnedView;
}