I really don't know a solution or even an idea to get around the following failure. It only happens in Release Configuration on the Device - Simulator and Debug Configuration work fine. It also only appears on the second launch. So if I have the phone connected to my mac, build the application and run it, everything works fine. If I then close the app and restart, it crashes. After long search, it seems that the error comes from the following line:
x.majorIntervalLength = CPDecimalFromFloat(2.0f);
The code before:
CPLayerHostingView *chartView = [[CPLayerHostingView
alloc] initWithFrame:CGRectMake(0, 0, 320, 160)];
[self addSubview:chartView];
// create an CPXYGraph and host it inside the view
CPTheme *theme = [CPTheme themeNamed:kCPPlainWhiteTheme];
CPXYGraph *graph = (CPXYGraph *)[theme newGraph];
chartView.hostedLayer = graph;
graph.paddingLeft = 20.0;
graph.paddingTop = 10.0;
graph.paddingRight = 10.0;
graph.paddingBottom = 20.0;
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange
plotRangeWithLocation:CPDecimalFromFloat(0)
开发者_如何学Go length:CPDecimalFromFloat(100)];
plotSpace.yRange = [CPPlotRange
plotRangeWithLocation:CPDecimalFromFloat(0)
length:CPDecimalFromFloat(10)];
CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
CPXYAxis *x = axisSet.xAxis;
x.majorIntervalLength = CPDecimalFromFloat(2.0f);
If I comment the last line, everything works fine (off course the interval length is not correct). I would appreciate any help! Thanks in advance!
Any chance CPXYAxis *x = axisSet.xAxis;
is an x that is nil
or not retained? It is not being checked for.
精彩评论