title: "unrecognized selector" error when trying to dismiss keyboard
body: <p>I'm trying to dismiss the keyboard when the user presses a "cancel" UIBarButtonItem. When I click the cancel button however, I get a SIGABRT with the "unrecognized selector sent to instance" error.</p>
  
  <p>My code to create the cancel button is:</p>
  
  <pre><code>- (void)keyboardWasShown:(NSNotification*)aNotification
  {
      //Add cancel button to navigation bar
      UIBarButtonItem *dismissKeyboardBttn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismissKeyboard:)];
      self.navigationItem.rightBarButtonItem = dismissKeyboardBttn;
  }
  </code></pre>
  
  <p>And to dismiss the keyboard I have this method:</p>
  
  <pre><code>- (void)dismissKeyboard:(id)sender
  {
      [activeField resignFirstResponder];
      //^^This line causes the SIGABRT^^
  }
  </code></pre>
  
  <p>It seems pretty straightforward. Any ideas?</p>
  
  <p>UPDATE: activeField is just a UITextField I'm using to move my scrollView to the UITextField the user is currently editing. It is set in these two methods: </p>
  
  <pre><code>- (void)textFieldDidBeginEditing:(UITextField *)textField 
  { 
      activeField = textField; 
  }
  - (void)textFieldDidEndEditing:(UITextField *)textField 
  { 
      activeField = nil; 
  }
  </code></pre>
  
  <p>UPDATE 2: Interesting, I have registered my ViewController to receive keyboard notifications, and when I try to dismiss the keyboard using the "textFieldShouldReturn" method, I get the same error. Here is my textFieldShouldReturn code:</p>
  
  <pre><code>- (BOOL)textFieldShouldReturn:(UITextField *)textField {
  
      if ([textField canResignFirstResponder])
      {
          [textField resignFirstResponder];
      }
  
      return YES;
  }
  </code></pre>