我正在使用此类显示名为 Action sheet picker的日期选择器,我遇到的问题是我无法设置选择器的最大和最小日期。
我正在使用的代码是这样的:
在 tableview didSelectRow 方法中:
else if (indexPath.row == 2){
// here I am using a library which successfully shows a date picker from where we can pick the dates on which we want to request the appt.
_actionSheetPicker = [[ActionSheetDatePicker alloc] initWithTitle:@""
datePickerMode:UIDatePickerModeTime selectedDate:self.selectedDateandTime
target:self action:@selector(dateWasSelected:element:) origin:[self.tableView
cellForRowAtIndexPath:indexPath]];
[self.actionSheetPicker addCustomButtonWithTitle:[self.selectedDateandTime
getDateStringInFormat:@"dd MMM yyyy"] value:Nil];
UIDatePicker * picker = (UIDatePicker *)[self.actionSheetPicker
configuredPickerView];
[picker setMinimumDate:self.selectedDateandTime];
self.actionSheetPicker.hideCancel = NO;
[self.actionSheetPicker showActionSheetPicker];
}
配置的PickerView 方法在库中,如下所示:
- (UIView *)configuredPickerView {
CGRect datePickerFrame = CGRectMake(0, 40, self.viewSize.width, 216);
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:datePickerFrame];
datePicker.datePickerMode = self.datePickerMode;
[datePicker setDate:self.selectedDate animated:NO];
[datePicker addTarget:self action:@selector(eventForDatePicker:) forControlEvents:UIControlEventValueChanged];
//need to keep a reference to the picker so we can clear the DataSource / Delegate when dismissing (not used in this picker, but just in case somebody uses this as a template for another picker)
self.pickerView = datePicker;
return datePicker;
}
请如果有人可以帮助我解决这个问题。如果需要任何额外的帮助来理解课程的架构,那么请随时问我。