如何在Core Plot饼图中启用触摸选择部分?

我正在使用Core Plot框架绘制饼图,并且在绘制饼图本身时没有任何问题。 但是,我需要饼图本质上是交互式的,即,如果我点击饼图中的任何特定部分,它应该触发导航到显示该特定部分的详细信息的页面。 我尝试使用方法
-(void)pieChart:sliceWasSelectedAtRecordIndex:
,但从未调用该委托方法。启用此触摸交互需要什么?     
已邀请:
我已经在我的iPad应用程序中使用CorePlot 0.2.2实现了饼图选择。你的猜测使用 (void)pieChart:sliceWasSelectedAtRecordIndex:是正确的,但也许你已经忘记了 声明以下两件事: 你的控制器是否声明了CPPieChartDelegate协议? 你告诉饼图你的控制器是它的委托吗? 我的视图控制器在标头声明中看起来像这样:
@interface YourViewController : UIViewController < CPPieChartDataSource,
                                                   CPPieChartDelegate,
                                                   ... >
{
   ...
   CPXYGraph*          pieGraph;
   CPGraphHostingView* pieView;
}

@property (nonatomic, retain) IBOutlet CPGraphHostingView* pieView;

- (void)pieChart:(CPPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index;

@end
在(void)viewDidLoad期间调用饼图的创建,我在其中设置数据源和饼图的委托:
-(void)viewDidLoad {
   [self createPie];
}

-(void)createPie {
   pieGraph = [[CPXYGraph alloc] initWithFrame:CGRectZero];
   pieGraph.axisSet = nil;
   self.pieView.hostedGraph = pieGraph;

   CPPieChart *pieChart = [[CPPieChart alloc] init];

   // This is important in order to have your slice selection handler called!
   pieChart.delegate = self;

   pieChart.dataSource = self;

   pieChart.pieRadius = 80.0;
   [pieGraph addPlot:pieChart];
   [pieChart release];
}

- (void)pieChart:(CPPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index {
   // Do whatever you need when the pie slice has been selected.
}
    
使用最后的
corePlot framework (1.4)
我找不到
CPPieChart
但我用
CPTPieChartDelegate
修复:
@interface CPDFirstViewController : UIViewController <CPTPlotDataSource, CPTPieChartDelegate, ...>
而这个方法:
-(void)pieChart:(CPTPieChart *)pieChart sliceWasSelectedAtRecordIndex:(NSUInteger)index
{
  // Put your action here
}
CPPieChartDelegate
不再被Xcode代表使用
CorePlot 1.4
识别 希望能帮助到你。 DOM     

要回复问题请先登录注册