how to set MaxDate and MinDate to DatePicker returned from webservice on ios
I have a an XML response which returns the below data as response
Start Day of the Week-Wednesday
End Day of the Week-开发者_开发问答Sunday
Start time -16:00
End time -19:00
Now I know how to parse these values ,but I am getting confused on how can I set these values to MaxDate and MinDate of the Date Picker,because the returned response is not same always and may change later,I mean later start day of the week ,end day of the week may change,so how shall I implement it so that it will be efficient..please help me friends..I tried some code which is below,but I am not sure whether i am on the right path,so please show me direction and help me out
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
[Gregorian setfirstDayofWeek:2];
NSDateComponents * comps =[[NSDateComponents alloc]init];
[comps setday:7];
So I suggest you to create two UIDatePicker
's or one custom UIDatePicker
.
If you will select first approach, you can set ranges of time in UIDatePicker
in following way:
Using IB:
- Select your
Date picker
. - Open
Utilities -> Attribute inspector
- In block
Constraints
: - Select
Minimum Date
and set its value01/01/1970 16:00:00
- Select
Maximum Date
and set its value01/01/1970 19:00:00
- Set value
Date
to01/01/1970 16:00:00
精彩评论