好的,没问题,我已经解决了我的问题。
的方式是覆盖在按钮触摸方法也是这样的:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touchMoved = NO;
[[self superview] touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
touchMoved = YES;
[[self superview] touchesMoved:touches withEvent:event];
[super touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!touchMoved) [super touchesEnded:touches withEvent:event];
}
的touchMoved
变量是为了跟踪,如果它是直接触摸到按钮或者如果触摸是为了拖超级观点。由于我使用的是UIControlEventTouchUpInside
,因此如果我在跟踪触摸移动时禁用touchesEnded,它就可以正常工作。
试着接受你以前的答案...... – Aravindhan