MM / YYYY UIPickerView

:  ~ 1 min read

Simple to use UIPickerView for those pesky Credit Card expiration dates, or any other mm-yyyy need you might have.

Comes with a slew of delegate methods and access to the currently selected month and year:

- (void)pickerDidSelectRow:(NSInteger)row inComponent:(NSInteger)component;
- (void)pickerDidSelectMonth:(NSString *)month;
- (void)pickerDidSelectYear:(NSString *)year;
- (void)pickerDidSelectMonth:(NSString *)month andYear:(NSString *)year;
- (void)pickerDidPressDoneWithMonth:(NSString *)month andYear:(NSString *)year;
- (void)pickerDidPressCancel;
- (void)pickerDidPressCancelWithInitialValues:(NSDictionary *)initialValues;
@property (nonatomic, strong) NSString *year;
@property (nonatomic, strong) NSString *month;

It's easy to init:

/**
 *  Month / Year picker view, for those pesky Credit Card expiration dates and alike.
 *
 *  @param date           set to a date if you want the picker to be initialized with a specific month and year, otherwise it is initialized with the current month and year.
 *  @param shortMonths    set to YES if you want months to be returned as Jan, Feb, etc, set to NO if you want months to be returned as January, February, etc.
 *  @param numberedMonths set to YES if you want months to be returned as 01, 02, etc. This takes precedence over shortMonths if set to YES.
 *  @param showToolbar    set to YES if you want the picker to have a Cancel/Done toolbar.
 *
 *  @return a container view which contains the UIPicker and toolbar
 */
- (id)initWithDate:(NSDate *)date shortMonths:(BOOL)shortMonths numberedMonths:(BOOL)numberedMonths andToolbar:(BOOL)showToolbar;

And that's about it. You can grab it here; also available in pod LTHMonthYearPickerView form.