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]; }