CPTAxis委托方法未被调用

时间:2016-12-13 09:05:57

标签: ios objective-c core-plot

// Grid line styles
CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
majorGridLineStyle.lineWidth = 0.5;
majorGridLineStyle.lineColor = [[CPTColor colorWithGenericGray:0.6] colorWithAlphaComponent:0.75];

CPTMutableLineStyle *minorGridLineStyle = [CPTMutableLineStyle lineStyle];
minorGridLineStyle.lineWidth = 0.25;
minorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.1];

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x          = axisSet.xAxis;
x.labelingPolicy              = CPTAxisLabelingPolicyAutomatic;
x.orthogonalCoordinateDecimal = CPTDecimalFromUnsignedInteger(0);
x.majorGridLineStyle          = majorGridLineStyle;
x.minorGridLineStyle          = minorGridLineStyle;
x.preferredNumberOfMajorTicks = 4;
x.minorTicksPerInterval       = 1;

// pin axis to bottom
x.axisConstraints             = [CPTConstraints constraintWithLowerOffset:0.0];

// Y axis
CPTXYAxis *y = axisSet.yAxis;
y.labelingPolicy              = CPTAxisLabelingPolicyAutomatic;
y.orthogonalCoordinateDecimal = CPTDecimalFromUnsignedInteger(0);
y.majorGridLineStyle          = majorGridLineStyle;
y.minorGridLineStyle          = minorGridLineStyle;
y.preferredNumberOfMajorTicks = 5;
y.minorTicksPerInterval       = 1;
y.delegate = self;

// Pin axis to left
y.axisConstraints             = [CPTConstraints constraintWithLowerOffset:0.0];

我正在尝试使用 - (BOOL)轴:(CPTAxis *)轴shouldUpdateAxisLabelsAtLocations:(NSSet *)位置但未按How to set custom tick marks in Core Plot to icons?中的建议调用。

1 个答案:

答案 0 :(得分:0)

确保委托类符合<CPTAxisDelegate>协议,并且方法具有正确的签名:

-(BOOL)axis:(nonnull CPTAxis *)axis shouldUpdateAxisLabelsAtLocations:(nonnull CPTNumberSet *)locations;