As others have pointed out: You are left alone, to create your own picker, but actually this isn't difficult. A quick prototype, note that I use the first componet for days, second for years, this should be made acording to locale in a real world app:
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}
-(NSInteger)pickerView:pickerView numberOfRowsInComponent:(NSInteger)component
{
NSUInteger number = 0;
if (component == 1) {
number = 12;
} else {
NSDateComponents *comps = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]];
NSUInteger month = [pickerView selectedRowInComponent:1]+1 ;
NSUInteger actualYear = [comps year];
NSDateComponents *selectMothComps = [[NSDateComponents alloc] init];
selectMothComps.year = actualYear;
selectMothComps.month = month;
selectMothComps.day = 1;
NSDateComponents *nextMothComps = [[NSDateComponents alloc] init];
nextMothComps.year = actualYear;
nextMothComps.month = month+1;
nextMothComps.day = 1;
NSDate *thisMonthDate = [[NSCalendar currentCalendar] dateFromComponents:selectMothComps];
NSDate *nextMonthDate = [[NSCalendar currentCalendar] dateFromComponents:nextMothComps];
NSDateComponents *differnce = [[NSCalendar currentCalendar] components:NSDayCalendarUnit
fromDate:thisMonthDate
toDate:nextMonthDate
options:0];
number = [differnce day];
}
return number;
}
-(void)pickerView:pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (component == 1) {
[pickerView reloadComponent:0];
}
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [NSString stringWithFormat:@"%d", row+1];
}
you'll find an example code at GitHub
The version you'll find on GitHub knows about the month's names of the most preferred language
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…