好的,沒問題,我已經解決了我的問題。
的方式是覆蓋在按鈕觸摸方法也是這樣的:
- (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