我自己找到了解决方案。
在核心情节的源代码,我看到了这一点:
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