我自己找到了解決方案。
在覈心情節的源代碼,我看到了這一點:
CGPoint lastPoint = self.touchedPoint;
// omit some codes......
// !!!!! the second condition of the if sentence cause my problem !!!!!
if (CGRectContainsPoint(self.bounds, plotAreaPoint) && CGPointEqualToPoint(plotAreaPoint, lastPoint)) {
if ([theDelegate respondsToSelector:@selector(plotAreaTouchUp:)]) {
[theDelegate plotAreaTouchUp:self];
}
if ([theDelegate respondsToSelector:@selector(plotAreaTouchUp:withEvent:)]) {
[theDelegate plotAreaTouchUp:self withEvent:event];
}
if ([theDelegate respondsToSelector:@selector(plotAreaWasSelected:)]) {
[theDelegate plotAreaWasSelected:self];
}
if ([theDelegate respondsToSelector:@selector(plotAreaWasSelected:withEvent:)]) {
[theDelegate plotAreaWasSelected:self withEvent:event];
}
return NO; // don't block other events in the responder chain
}
在真實設備的環境下,觸摸開始點和觸摸終點通常是彼此不同的,他們總是不一樣的。
所以條件CGPointEqualToPoint(plotAreaPoint, lastPoint)
總是假的,if語句中的代碼永遠不會被執行。
爲了適應這一點,我刪除了第二個條件中,如果:
if (CGRectContainsPoint(self.bounds, plotAreaPoint)) { ... }
它解決了。
我剛剛在[Core Plot](https://github.com/core-plot/core-plot)中解決了這個問題。我改變了你取消的檢查,以便它允許終點距離起點最多5個點,並且仍然激發委託上的選擇方法。 – 2014-09-25 00:50:40