From 6b2770ac1e2d8b1775accfde6df80455e47dcf38 Mon Sep 17 00:00:00 2001 From: yls <2008.yls@163.com> Date: Mon, 9 Jun 2014 13:49:07 +0800 Subject: [PATCH] add -pieChart:ShouldSelectSliceAtIndex: method --- XYPieChart/XYPieChart.h | 1 + XYPieChart/XYPieChart.m | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/XYPieChart/XYPieChart.h b/XYPieChart/XYPieChart.h index 0300ecb..9ec09c0 100644 --- a/XYPieChart/XYPieChart.h +++ b/XYPieChart/XYPieChart.h @@ -44,6 +44,7 @@ - (void)pieChart:(XYPieChart *)pieChart didSelectSliceAtIndex:(NSUInteger)index; - (void)pieChart:(XYPieChart *)pieChart willDeselectSliceAtIndex:(NSUInteger)index; - (void)pieChart:(XYPieChart *)pieChart didDeselectSliceAtIndex:(NSUInteger)index; +- (BOOL)pieChart:(XYPieChart *)pieChart ShouldSelectSliceAtIndex:(NSUInteger)index; @end @interface XYPieChart : UIView diff --git a/XYPieChart/XYPieChart.m b/XYPieChart/XYPieChart.m index 1914413..9be6bf1 100644 --- a/XYPieChart/XYPieChart.m +++ b/XYPieChart/XYPieChart.m @@ -543,6 +543,11 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event - (void)notifyDelegateOfSelectionChangeFrom:(NSUInteger)previousSelection to:(NSUInteger)newSelection { + if ([_delegate respondsToSelector:@selector(pieChart:ShouldSelectSliceAtIndex:)]) { + if (![_delegate pieChart:self ShouldSelectSliceAtIndex:newSelection]) { + return; + }; + } if (previousSelection != newSelection){ if(previousSelection != -1){ NSUInteger tempPre = previousSelection;