title: date picker in ios application
body: <p>i am new to iPhone development. I want to add a <code>UIDatePicker</code> when textfield is selected.
  two date picker is there.</p>
  
  <pre><code>- (void)textFieldDidBeginEditing:(UITextField *)aTextField
  {
  
      [aTextField resignFirstResponder];
  
      pickerViewPopup = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  
      UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 44, 0, 0)];
      pickerView.datePickerMode = UIDatePickerModeDate;
      pickerView.hidden = NO;
      pickerView.date = [NSDate date];
  
      UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
      pickerToolbar.barStyle = UIBarStyleBlackOpaque;
      [pickerToolbar sizeToFit];
  
      NSMutableArray *barItems = [[NSMutableArray alloc] init];
  
      UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
      [barItems addObject:flexSpace];
  
      UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];
      [barItems addObject:doneBtn];
  
      UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)];
      [barItems addObject:cancelBtn];
  
      [pickerToolbar setItems:barItems animated:YES];
  
      [pickerViewPopup addSubview:pickerToolbar];
      [pickerViewPopup addSubview:pickerView];
      [pickerViewPopup showInView:self.view];
      [pickerViewPopup setBounds:CGRectMake(0,0,320, 464)];
  }
  </code></pre>
  
  <p>I used this but got same value for the two different datepickers. I want that if I press textfield1 then datepicker opens and saves that value in textfield one and same for the second textfield . Thanks.</p>