我正在使用代码的修改版本 here显示图表中沿图点的标注弹出窗口。我已经让它大部分工作了,但我遇到的问题是,当我滚动或缩放图表时,标注保持在屏幕上的同一位置,而不是随着点移动而跟随。
如果您想要一些代码示例来使用,这里就是。关于如何使标注随情节点移动有什么想法吗?谢谢!
-(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)idx {
if ([plot.identifier isEqual:_plotIdentifier]) {
NSArray *selectedSymbolItem = [self.data.xyArrays objectAtIndex:idx];
NSNumber *x = [selectedSymbolItem objectAtIndex:0];
NSNumber *y = [selectedSymbolItem objectAtIndex:1];
double doublePrecisionPlotPoint[2];
doublePrecisionPlotPoint[0] = x.doubleValue;
doublePrecisionPlotPoint[1] = y.doubleValue;
CGPoint pointTouched = [plot.graph.defaultPlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:doublePrecisionPlotPoint];
CGPoint convertedPoint = [plot.graph convertPoint:pointTouched toLayer:self.view.layer];
_popupView = [[SMCalloutView alloc] init];
_popupView.title = [NSString stringWithFormat:@"Thing %i", idx];
[_popupView presentCalloutFromRect:CGRectMake(convertedPoint.x, convertedPoint.y, 10, 10) inLayer:self.view.layer constrainedToLayer:self.hostView.layer permittedArrowDirections:SMCalloutArrowDirectionDown animated:YES];
}
}
最佳答案
使用绘图空间委托(delegate)来监视绘图空间的更改并根据需要更新标注位置。
关于ios - 核心图的标注不跟随滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14761025/