Just add a UIPickerView (NOT UIDatePickerView) and set the Datasource (and delegate) to your Class. Then in your Class add something like this:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 3;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
switch (component) {
case 0: // how many days? (you might find out how many days the month really had, instead of just returning 31
{
#if TARGET_IPHONE_SIMULATOR
return 50000;
// I don't now, what the exact Value for NSIntegerMax is, but 50000 should be enough for testing.
#else
return NSIntegerMax;
#endif
break;
}
case 1: // how many months to display?
{
#if TARGET_IPHONE_SIMULATOR
return 50000;
#else
return NSIntegerMax;
#endif
break;
}
case 2:
{
return 100; // how many years?
break;
}
}
return 0;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (component == 0) // days
return [NSString stringWithFormat:@"%i",(int)row % 31 + 1];
else if (component == 1) // month
{
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM"];
NSDate* myDate = [dateFormatter dateFromString:[NSString stringWithFormat:@"%i",(int)row % 12 + 1]];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMMM"];
return [formatter stringFromDate:myDate];
}
else if (component == 2 && row == ([pickerView numberOfRowsInComponent:2] - 1))
return @"-----";
else
{
// let's use NSDateFormatter to get the current year:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY"];
return [NSString stringWithFormat:@"%i",[[dateFormatter stringFromDate:[NSDate date]] integerValue] - ([pickerView numberOfRowsInComponent:2] - 1) + (row + 1)];
}
}
Result looks like this:

You might implement the
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
in order to change the width for each component.