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;