I'm using CPTScatterPlot to display data, also I have data labels above all plot symbols. I need to detect user touches and using - plot:dataLabelWasSelectedAtRecordIndex: to detect it. But if I click on the data label and try to scroll, scrolling is not working.

Is there any way to detect if user touches and yet not interrupt scrolling?

有帮助吗?

解决方案 2

I fix this problem in my code, using graph plot space delegate instead of CPTPlot delegate.

-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(CPTNativeEvent *)event atPoint:(CGPoint)point {
    _lastPlotSpaceDownPoint=point;
    return YES;
}

-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(CPTNativeEvent *)event atPoint:(CGPoint)point {
    CGFloat distance = hypotf((_lastPlotSpaceDownPoint.x - point.x), (_lastPlotSpaceDownPoint.y - point.y));
    if (abs(distance) < 5) {
        NSUInteger recordIndex=[self.linePlot indexOfVisiblePointClosestToPlotAreaPoint:point];
        // your code here
    }
    return YES;
}

其他提示

We've made some changes to the event handling and related delegate methods on the release-2.0 branch of the Core Plot code. Get the latest code from GitHub and switch to the release-2.0 branch to get the updated code. Note that this update requires the Accelerate framework and raises the minimum system requirements from the 1.x releases on the master branch.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top