ボタンをクリックすると、日付ピッカーを正常に表示できますが、日付ピッカーから日付を選択すると、選択した日付を表示できませんUIbutton
。助けてください
これが私のコードです:
-(IBAction)btnDateClicked:(id)sender
{
UIActionSheet *actionSheet1 = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet1 setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
UIDatePicker *pView=[[UIDatePicker alloc] initWithFrame:pickerFrame];
pView.datePickerMode=UIDatePickerModeDate;
NSDateFormatter *df=[[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yyyy"];
// NSDate *date=[df dateFromString:self.hController.fromDateTime];
// [pView setDate:date animated:YES];
self.datePicker=pView;
[actionSheet1 addSubview:self.datePicker];
[pView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet1:) forControlEvents:UIControlEventValueChanged];
[actionSheet1 addSubview:closeButton];
[closeButton release];
[actionSheet1 showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet1 setBounds:CGRectMake(0, 0, 320, 485)];
self.actionSheet=actionSheet1;
[actionSheet1 release];
}
///////////////////////////////////
- (void)dismissActionSheet1:(id)sender
{
[self.actionSheet dismissWithClickedButtonIndex:0 animated:YES];
NSDateFormatter *df=[[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yyyy"];
//NSString *str=[df stringFromDate:self.datePicker.date];
//self.hController.selectDate=str;
}