声明
赋值
开始回调
使用
NSInvocation* m_touchDown;
赋值
-(void) setTouchMoveCallback:(id) target sel:(SEL) sel {
if (m_touchMove) {
[m_touchMove release];
m_touchMove = nil;
}
NSMethodSignature *sig= [target methodSignatureForSelector:sel];
NSAssert(sig, @"");
m_touchMove = [NSInvocation invocationWithMethodSignature:sig];
[m_touchMove setTarget:target];
[m_touchMove setSelector:sel];
[m_touchMove setArgument:&self atIndex:2];
[m_touchMove retain];
}
开始回调
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
if (m_touchDown) {
[m_touchDown setArgument:&touch atIndex:3];
[m_touchDown setArgument:&event atIndex:4];
[m_touchDown invoke];
}
return YES;
}
使用
[btn setTouchDownCallback:self sel:@selector(eventTouchBegin:touch:event:)];
回调函数
-(void) eventTouchBegin:(myButton*) sender touch:(UITouch*) touch event:(UIEvent*) event {
// TODO
}