From ceaf64e7e54667e20433e0d912e725364fc3086e Mon Sep 17 00:00:00 2001 From: Dmitriy Shulzhenko Date: Wed, 9 Nov 2016 00:57:33 +0200 Subject: [PATCH] - (void)pickerView:(AKPickerView *)pickerView willSelectItem:(NSInteger)item; method added to delegate --- AKPickerViewSample/AKPickerView/AKPickerView.h | 1 + AKPickerViewSample/AKPickerView/AKPickerView.m | 3 +++ 2 files changed, 4 insertions(+) diff --git a/AKPickerViewSample/AKPickerView/AKPickerView.h b/AKPickerViewSample/AKPickerView/AKPickerView.h index e0f0923..715c6e4 100644 --- a/AKPickerViewSample/AKPickerView/AKPickerView.h +++ b/AKPickerViewSample/AKPickerView/AKPickerView.h @@ -26,6 +26,7 @@ typedef NS_ENUM(NSInteger, AKPickerViewStyle) { @protocol AKPickerViewDelegate @optional - (void)pickerView:(AKPickerView *)pickerView didSelectItem:(NSInteger)item; +- (void)pickerView:(AKPickerView *)pickerView willSelectItem:(NSInteger)item; - (CGSize)pickerView:(AKPickerView *)pickerView marginForItem:(NSInteger)item; - (void)pickerView:(AKPickerView *)pickerView configureLabel:(UILabel * const)label forItem:(NSInteger)item; @end diff --git a/AKPickerViewSample/AKPickerView/AKPickerView.m b/AKPickerViewSample/AKPickerView/AKPickerView.m index 9d1b255..c0680c9 100644 --- a/AKPickerViewSample/AKPickerView/AKPickerView.m +++ b/AKPickerViewSample/AKPickerView/AKPickerView.m @@ -353,6 +353,9 @@ - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UIColl - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + if ([self.delegate respondsToSelector:@selector(pickerView:willSelectItem:)]) + [self.delegate pickerView:self willSelectItem:indexPath.item]; + [self selectItem:indexPath.item animated:YES]; }