title: Dismiss iPhone keyboard triggered by a UITextField in a Subview
body: <p>My <strong><code>ViewController</code></strong> contains a <strong>subview</strong>:</p>
  
  <p>The <strong>sub <code>UIView</code></strong> is located in <strong><code>NameSubViewController</code> (class with XIB)</strong>.  </p>
  
  <p>Subview contains a <strong><code>UITextField</code></strong>.</p>
  
  <hr>
  
  <p>I added this action:</p>
  
  <p><strong><code>- (IBAction)textFieldReturn:(id)sender;</code></strong> </p>
  
  <p>in the <strong><code>NameSubViewController</code></strong> class and connected it to the textfield (did end on exit) from Files Owner in XIB. </p>
  
  <p>But log gives me an error message when I hit return, and nothing happens in simulator.</p>
  
  <p>This is the relevant code:</p>
  
  <hr>
  
  <p><strong>ViewController.h:</strong></p>
  
  <pre><code>@property (nonatomic, strong) UIView *nameSubView;
  </code></pre>
  
  <p><strong>ViewController.m (viewDidLoad):</strong></p>
  
  <pre><code>UIViewController *nameController = [[NameSubViewController alloc] initWithNibName:@"NameSubViewController" bundle:nil];
  nameSubView = [nameController view];
  
  [self.view addSubview:nameSubView];
  </code></pre>
  
  <hr>
  
  <p><strong>NameSubViewController.h:</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface NameSubViewController : UIViewController
  
  @property (nonatomic, strong) IBOutlet UITextField *textField;
  
  - (IBAction)textFieldReturn:(id)sender;
  //Not working.. Connected from files owner to textField with option didEndOnExit
  </code></pre>
  
  <p><strong>NameSubViewController.m:</strong></p>
  
  <pre><code>-(IBAction)textFieldReturn:(id)sender
  {
  [sender resignFirstResponder];
  } 
  </code></pre>
  
  <hr>
  
  <p><strong>When I hit return I get this message in the log:</strong></p>
  
  <p><code>AppName[6656:f803] -[CALayer textFieldReturn:]: unrecognized selector sent to instance 0x6e99d40
  2012-08-28 02:51:26.954 AppName[6656:f803] *** WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: &lt;NSInvalidArgumentException&gt; -[CALayer textFieldReturn:]: unrecognized selector sent to instance 0x6e99d40</code></p>
  
  <p><strong>and keyboard is not dismissed. What could cause my issue?</strong></p>
  
  <p>The ViewController:</p>
  
  <p><a href="http://www.flickr.com/photos/80427098@N07/7877111708/in/photostream" rel="nofollow">http://www.flickr.com/photos/80427098@N07/7877111708/in/photostream</a></p>
  
  <p>The NameSubViewController, view which is displayed in the subView of ViewController:</p>
  
  <p><a href="http://www.flickr.com/photos/80427098@N07/7877111596/in/photostream" rel="nofollow">http://www.flickr.com/photos/80427098@N07/7877111596/in/photostream</a></p>