【发布时间】:2013-12-06 10:14:49
【问题描述】:
我正在使用 UIdatepicker。我正在从日期选择器中获取时间并在标签上显示日期。一旦我选择了它显示在标签上的日期,日期选择器就会被隐藏起来。现在我希望当我调用选择器时,它应该在我之前在 datepicker 上选择的标签的日期上显示 datepicker 的选择栏。我正在使用的代码如下所示:-
-(void)datepickershown:(UILabel *)time animated:(BOOL)animated
{
UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:@"Select the Time" delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"DONE" otherButtonTitles:Nil, nil];
pickdate = [[UIDatePicker alloc] initWithFrame:[actionsheet bounds]];
pickdate.hidden = NO;
//pickdate.date = [NSDate date];
pickdate.datePickerMode = UIDatePickerModeTime;
[pickdate addTarget:self action:@selector(changeDateInLabel:) forControlEvents:UIControlEventValueChanged];
[actionsheet addSubview:pickdate];
[actionsheet showInView:self.view];
[actionsheet setBounds:CGRectMake(0,0,320, 500)];
CGRect pickerRect = pickdate.bounds;
pickerRect.origin.y = -90;
pickdate.bounds = pickerRect;
}
- (IBAction)changeDateInLabel:(id)sender
{
NSLog(@"I Am Changing the values");
df = [[NSDateFormatter alloc] init];
df.timeStyle = NSDateFormatterShortStyle;
}
【问题讨论】:
-
请详细说明:'现在我希望当我调用选择器时,它应该在我之前在日期选择器上选择的标签的日期显示日期选择器的选择栏。'跨度>
-
我正在添加带有描述的图像,请看看希望你能理解。
-
sry 我添加了图像因为声誉..
-
其实我想要的是,我从 datepicker 设置标签上的时间。一旦我选择了时间和日期选择器关闭,然后我发现我选择的时间是错误的,现在我再次打电话让选择器出现。现在我希望选择器显示我之前选择的日期。但它向我显示了当前日期。
标签: ios iphone datepicker