Friday, 14 June 2013

Hide Keyboard iOS.


Hide Keyboard in UITextView.
Set Delegate of UITextView to self.



-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if([text isEqualToString:@"\n"])
        [textView resignFirstResponder];
    return YES;
}



Hide Keyboard in UITextField.  
Set Delegate of UITextField to self.
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField == yourTextField){
      [yourTextfield resignFirstResponder];
    }
}


See Links:
http://stackoverflow.com/questions/703754/how-to-dismiss-keyboard-for-uitextview-with-return-key

http://www.techotopia.com/index.php/Writing_Code_to_Hide_the_iPhone_Keyboard

No comments:

Post a Comment