Is there a way to have a UIDatePicker show year only?
I cannot comment, but I was playing around with the answer by Wolvorin and I decided to do a way where the most recent year would be at the top of the Picker. Currently, his code goes oldest to most recent years.
All I changes was in my NSMutableArray setup in the viewDidLoad instead of his:
//Create Years Array from 1960 to This year
years = [[NSMutableArray alloc] init];
for (int i=1960; i<=i2; i++) {
[years addObject:[NSString stringWithFormat:@"%d",i]];
}
I used:
years = [[NSMutableArray alloc] init];
for (int i1=i2; i1<=i2 & i1>=1920; i1--) {
[years addObject:[NSString stringWithFormat:@"%d",i1]];
}
Which does the for in reversed order going from the most recent date, then subtracting one year (and adding it to the Array) until it gets to 1920.
My formula:
int i1=i2; i1<=i2 & i1>=1920; i1--