문제

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