문제

I'm interested in registering, if the user hit the min or max date while using a UIDatePicker. Is there a way to do so? Thanks.

도움이 되었습니까?

해결책

First, add a method that listens to value changes in the date picker itself:

[datePicker addTarget:self action:@selector(datePickerDateChanged:) forControlEvents:UIControlEventValueChanged];

Then, in the method, compare the date of the date picker with the min or max date:

- (void)datePickerDateChanged:(UIDatePicker*)picker {
    if ([picker.date compare:picker.maximumDate] == NSOrderedSame) {
        // max
    } else if ([picker.date compare:picker.minimumDate] == NSOrderedSame) {
        // min
    }
}

Hope that hepls. Good luck!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top