UIDatePicker view in iPhone [closed]
How to pass time from NSString
in UIDatePickerView
-(void)viewDidLoad {
[super viewDidLoad];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
NSString * date = @"2010-12-10";
[dateFormat setDateFormat:@"yyyy'-'MM'-'dd"];
NSDate *anyDate = [dateFormat dateFromString:date];
[datePicker setDate:anyDate];
[dateFormat release];
}
didn't test it, but should work.. or else point you in the right direction
edit for time:
-(void)viewDidLoad {
[super viewDidLoad];
NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init];
NSString * time = @"08:00-am";
[timeFormat setTimeFormat:@"hh':'mm'-'tt"];
NSDate *anyTime = [timeFormat dateFromString:time];
[datePicker setTime:anyTime];
[timeFormat release];
}
精彩评论