/ Published in: Objective C

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
- (void)viewDidLoad { addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } - (void)dealloc { } CGRect start, end; // position of keyboard before animation [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&start]; // and after.. [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&end]; double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; int curve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]; // slide view up.. [UIView beginAnimations:@"foo" context:nil]; [UIView setAnimationDuration:duration]; [UIView setAnimationCurve:curve]; self.view.frame = CGRectMake(0, -end.size.width, 480, 320); [UIView commitAnimations]; } double duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; int curve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]; // slide view down [UIView beginAnimations:@"foo" context:nil]; [UIView setAnimationDuration:duration]; [UIView setAnimationCurve:curve]; self.view.frame = CGRectMake(0, 0, 480, 320); [UIView commitAnimations]; }
Comments
