hide keyboard on pickerview textfield
<p>I have implemented a view, in which there is two text fields. At first text field, when user click on it, there is a display of picker view. When user clicks on other text field keyboard is shown. But when user go from second text field to first text field it still shows the keyboard and there is a picker view on the back of this keyboard. I am unable to resign this keyboard when user move from second to first textfield without pressing keyboard done button.</p>

<pre><code> -(void)textFieldDidBeginEditing:(UITextField *)myTextField
  {  
  if(myTextField == firsttextfield)
  {
    [firsttextfield resignFirstResponder];
    medicationtypepicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,190,320,215)];
    medicinetypearray = [[NSMutableArray alloc]initWithObjects:@"Capsules",@"Eyedrops", 
    @"Eardrops",@"Nosedrops",@"Inhaler",@"Syrup",@"Injections",@"Oils",@"Ointment", nil];
    medicationtypepicker.delegate = self;
    medicationtypepicker.showsSelectionIndicator = YES;
    medicationtypepicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:medicationtypepicker];
   }
</code></pre>

<p>}</p>

<pre><code>   -(BOOL)textFieldShouldReturn:(UITextField *)textField
    {
     [secondtextfield resignFirstResponder];
     return YES;
     }
</code></pre>

<p><img src="http://i.stack.imgur.com/dwbwf.png" alt="enter image description here"></p>

<p>if some one has idea to dismiss the keyboard. Please provide the solution.</p>

<p>Thankyou very much.</p>
