当前位置: 首页 > 工具软件 > AQGridView > 使用案例 >

Xcode6环境下AQGridView编译错误:'too many arguments to function call, expected 0, have 4'

桂智志
2023-12-01

修改代码如下:

- (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;
}

参考: https://github.com/AlanQuatermain/AQGridView/pull/211/files?diff=split

 类似资料: