Return to Snippet

Revision: 45367
at April 29, 2011 00:29 by bethjt1220


Initial Code
/*
 * Gets rid of the keyboard when the user taps the background.
 */
- (IBAction) backgroundTap: (id) sender {
    [titleField resignFirstResponder];
    [description resignFirstResponder];
}

/*
 * Gets rid of the keyboard during edting when the "Return" key is pressed.
 * (works for a UITextView)
 */
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range 
 replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return FALSE;
    }
    return TRUE;
}

/*
 * Gets rid of the keyboard during edting when the "Return" key is pressed.
 * (works for a UITextField)
 */
-(IBAction) textFieldDoneEditing:(id)sender {
    [sender resignFirstResponder];
}

Initial URL


Initial Description
background tap - background should have type UIControl and method should be connected to the "touch down" action
textView - doesn't need to be connected to an action, but delegate needs to be connected to something that is a UITextViewDelegate
textField - delegate needs to be connected to something that is a UITextFieldDelegate and method should be connected to the "did end on exit" action

Initial Title
Remove Keyboard

Initial Tags
ios

Initial Language
iPhone