- (void)viewDidLoad
{
graph = [[CPTXYGraph alloc] initWithFrame: self.view.bounds];
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.hostedGraph = graph;
CPTPieChart *pieChart = [[CPTPieChart alloc] init];
pieChart.dataSource = self;
pieChart.pieRadius = 100.0;
pieChart.identifier = @"PieChart1";
pieChart.startAngle = M_PI_4;
pieChart.sliceDirection = CPTPieDirectionCounterClockwise;
self.pieData= [NSMutableArray arrayWithObjects:[NSNumber numberWithDouble:90.0],
[NSNumber numberWithDouble:20.0],
[NSNumber numberWithDouble:30.0],
[NSNumber numberWithDouble:40.0],
[NSNumber numberWithDouble:50.0],
[NSNumber numberWithDouble:60.0], nil];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[graph applyTheme:theme];
[graph addPlot:pieChart];
[pieChart release];
}
我在网上找到了这段代码。这段代码工作正常,但在
收到了两条警告
pieChart.dataSource = self;
它说。
warning: class 'SOTC_CorePlotExampleViewController' does not implement the 'CPTPlotDataSource' protocol
warning: Semantic Issue: Assigning to 'id' from incompatible type 'SOTC_CorePlotExampleViewController *'
最佳答案
添加<CPTPlotDataSource>
到您的@interface (.h) 文件中自定义 View Controller 声明的末尾:
@interface YourViewController : UIViewController <CPTPlotDataSource>
(将我示例中的 YourViewController 更改为您的 View Controller 的名称)
关于iphone - 执行 CorePlot 代码时出现警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8267629/