title: ResignFirstResponder from Keyboard AccessoryView Button
body: <p>In my View i have 3 UITextField, for each of them i created an accessoryView for keyboard as explained by <a href="http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/InputViews/InputViews.html" rel="nofollow">apple</a>. </p>
  
  <p>In my accessoryView i added a button which has to call function "CloseKeyboard". In this function i cant find a way to intercept the UITextField in which keyboard is writing and on which i need to call ResignFristResponder.</p>
  
  <p>To add accessoryView on one field i wrote that code</p>
  
  <pre><code>if (field1.inputAccessoryView == nil) {
      field1.inputAccessoryView = [self createInputAccessoryView];   
  }
  if (field2.inputAccessoryView == nil) {
      field2.inputAccessoryView = [self createInputAccessoryView];   
  }
  if (field3.inputAccessoryView == nil) {
      field3.inputAccessoryView = [self createInputAccessoryView];   
  }
  </code></pre>
  
  <p>And here createInputAccessory function: </p>
  
  <pre><code>-(UIView *)createInputAccessoryView {
  
      CGRect accessFrame = CGRectMake(0.0, 0.0, 20.0, 55.0);
  
      UIView *inputAccessoryView = [[UIView alloc] initWithFrame:accessFrame];
  
      UIButton *compButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  
      compButton.frame = CGRectMake(250.0, 10.0, 60.0, 40.0);
  
      [compButton setTitle: @"Close" forState:UIControlStateNormal];
  
      [compButton addTarget:self action:@selector(CloseKeyboard:)
  
                          forControlEvents:UIControlEventTouchUpInside];
  
      [inputAccessoryView addSubview:compButton];
  
  return inputAccessoryView; }
  </code></pre>
  
  <p>How can i implement the "CloseKeyboard" function to be able to resignFirstResponder from active UITextField ?  </p>
  
  <p>Thank you for your help!</p>