UIDatePicker upon date changed

When properly configured, a UIDatePicker object sends an action message when a user finishes rotating one of the wheels to change the date or time; the associated control event is UIControlEventValueChanged. so you need to add your class to handle UIControlEventValueChanged event in your picker: [picker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged]; … – (void) dateChanged:(id)sender{ // handle … Read more

UIDatePicker, setting maximum and minimum dates based on todays date

Not tested, but you probably want something like this. NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *currentDate = [NSDate date]; NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setYear:30]; NSDate *maxDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0]; [comps setYear:-30]; NSDate *minDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0]; [datePicker setMaximumDate:maxDate]; [datePicker setMinimumDate:minDate]; Update for Swift 4.1 let calendar = … Read more

Anyone find that UIDatePicker is broken under iOS 14?

To add some additional information to Oscar’s answer… UIDatePicker now has three different styles, as per documentation here and here. The date picker’s style is accessible by the .preferredDatePickerStyle property which can be set to four different cases: .automatic – A style indicating that the system picks the concrete style based on the current platform … Read more

UIControlEventEditingChanged doesn’t get fired when using setText of UITextfield

I had to rate this question up because this is super important. It appears this has changed in iOS6. Maybe even iOS5. This event USED to be the preferred method for observing text changes in a UITextField. I’ve been using it since iOS3. After recompiling my app on iOS6 to perform some updates, it mysteriously … Read more

jQuery Date Picker – disable past dates

You must create a new date object and set it as minDate when you initialize the datepickers <label for=”from”>From</label> <input type=”text” id=”from” name=”from”/> <label for=”to”>to</label> <input type=”text” id=”to” name=”to”/> var dateToday = new Date(); var dates = $(“#from, #to”).datepicker({ defaultDate: “+1w”, changeMonth: true, numberOfMonths: 3, minDate: dateToday, onSelect: function(selectedDate) { var option = this.id == … Read more