changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

Get rid of the iPhone keyboard when “Done”

August 1, 2010 by The Man

Another one I always forget. Get rid of the keyboard when the done button is pressed.

1. In IB make sure the delegate of the UITextField is set to the File’s Owner.

2. Add this code

-(BOOL) textFieldShouldReturn:(UITextField*) textField {
    [textField resignFirstResponder]; 
    return YES;

Easy really.