caldera.sac
caldera.sac

Reputation: 5108

How to set the second date picker's minimum date as first date picker's selected date and get the dates realtime in ios9

In my app there are two date picker's. for the first date picker view I have set the minimum date as current date like this

[self.firstDatePicker setMinimumDate:[NSDate date]];

then I want to set the minimum date for the second date picker should be the user selected date plus one day from the first date picker(selected date).

self.secondDatePicker.minimumDate = @"some thing"

help me wit this.

Upvotes: 0

Views: 418

Answers (1)

caldera.sac
caldera.sac

Reputation: 5108

this is what I did, and this question and answer helped me with this.

self.datepickerOne.minimumDate = [NSDate date];
    [self.datepickerOne addTarget:self action:@selector(updateDateFromPicker:) forControlEvents:UIControlEventValueChanged];

above I Set the minimum date for the first date picker. and after that get the selected date from the first datepicker

for that use this action method to update the selected date and at the same time I set the minimum date for the seconddate picker

- (IBAction)updateDateFromPicker:(id)sender
{
    NSLog(@"%@", self.datepickerOne.date);
    self.datepickerTwo.minimumDate = [self.datepickerOne.date dateByAddingTimeInterval:24*60*60];
}

hope this will help to others also.

Upvotes: 0

Related Questions