title: UITextView hide keyboard in iphone
body: <p>I want to hide keyboard when a user presses return in <code>UITextView</code> object in iphone. However, mysteriously this is not working for <code>UITextView</code> but working for <code>UITextField</code>. I am unable to figure out why...</p>
  
  <p>This is what I did:</p>
  
  <p>1) I created a view based application in XCode4.</p>
  
  <p>2) in .xib created <code>UITextView</code>, <code>UITextField</code> and <code>UIButton</code> objects</p>
  
  <p><em><strong>3) Marked both <code>UITextField</code> and <code>UITextView</code> delegates to File's Owner in Outlets</em></strong></p>
  
  <p>4) Added <code>&lt;UITextFieldDelegate&gt;</code> to @interface UIViewController in .h</p>
  
  <p>5) Added <code>textFieldShouldReturn</code> function in .m</p>
  
  <p>Here are the codes: </p>
  
  <p><strong>.h file</strong></p>
  
  <pre><code>@interface keyboardDisappearViewController : UIViewController &lt;UITextFieldDelegate&gt;
  {
  
      UITextView *textBoxLarge;
      UITextField *textBoxLittle;
  }
  @property (nonatomic, retain) IBOutlet UITextView *textBoxLarge;
  @property (nonatomic, retain) IBOutlet UITextField *textBoxLittle;
  
  - (IBAction)doSomething:(id)sender;
  @end
  </code></pre>
  
  <p><strong>.m file</strong></p>
  
  <pre><code>- (BOOL) textFieldShouldReturn:(UITextField *)theTextField 
  {
      NSLog(@"textFieldShouldReturn Fired :)");
      [textBoxLarge resignFirstResponder];
      [textBoxLittle resignFirstResponder];
      return YES;
  }
  </code></pre>
  
  <p>Amazingly, the keyboard is disappearing in case of textBoxLittle (UITextField) but not in case of textBoxLarge(UITextView)</p>
  
  <p>As a further check I, made the button to call function doSomething</p>
  
  <pre><code>- (IBAction)doSomething:(id)sender {
      [textBoxLarge resignFirstResponder];
      [textBoxLittle resignFirstResponder];
  }
  </code></pre>
  
  <p>When I am pressing the button, keyboard is disappearing in both textboxes.</p>
  
  <p>Its driving me nuts why textFieldShouldReturn is working for small textbox, but NOT for large textbox.</p>
  
  <p>Please Help!</p>