开发者

UIDatePicker view in iPhone [closed]

开发者 https://www.devze.com 2023-01-29 17:23 出处:网络
It's diffic开发者_C百科ult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. Fo
It's diffic开发者_C百科ult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消