To get notifications on keyboard hiding and showing, have a look at
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification object:[self view].window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification object:[self view].window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:[self view].window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:[self view].window];
and add appropriate methods like
-(void)keyboardWillShow:(NSNotification*)notif
-(void)keyboardWillHide:(NSNotification*)notif
-(void)keyboardDidShow:(NSNotification*)notif
-(void)keyboardDidHide:(NSNotification*)notif
Then you can connect the animations any way you like.
Be sure to NSLog() all of them, they are not always called when you would expect them (the notorious one being when you go from one field to another, and you receive the willhide and willshow immediately)