我有个问题。我需要更改 x 轴值比例。现在是 0, 0.5, 1.0, 1.5, 2.0... 我希望它是 0, 1, 2, 3... 我该怎么做呢?我正在使用的代码如下所示:
graph = [[CPTXYGraph alloc] initWithFrame:self.view.bounds];
[graph applyTheme:[CPTTheme themeNamed:kCPTDarkGradientTheme]];
CPTGraphHostingView *hostingView = (CPTGraphHostingView*)self.view;
hostingView.hostedGraph = graph;
graph.paddingTop = 20;
graph.paddingRight = 20;
graph.paddingLeft = 20;
graph.paddingBottom = 50;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace*)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromString(@"-0.5") length:CPTDecimalFromString(@"5")];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromString(@"-2.5") length:CPTDecimalFromString(@"5")];
plotSpace.allowsUserInteraction = YES;
CPTScatterPlot *mainPlot = [[[CPTScatterPlot alloc] initWithFrame:graph.bounds] autorelease];
CPTMutableLineStyle *line = [[CPTMutableLineStyle alloc] init];
[line setLineColor:[CPTColor blueColor]];
[line setLineWidth:1.5f];
mainPlot.identifier = @"Main Plot";
[mainPlot setDataLineStyle:line];
mainPlot.dataSource = self;
[graph addPlot:mainPlot];
[line release];
而且我还必须在视图底部添加一个按钮。我在 IB 中拔出一个按钮并将其连接到我的插座。我尝试通过使用将它放在前面,[hostingView.superview bringSubviewToFront:backButton];
但我没有任何运气。我该如何做到这一点?
编辑:我设法通过使用将该按钮带到前面,[self.view bringSubviewToFront:backButton];
但它反映了视图中间的按钮。不知道这怎么可能?它如何修复它?