- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self registerForKeyboardNotifications];
}
return self;
}
- (void) registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardWillShow:)name: UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardWillhiden:)name: UIKeyboardWillHideNotification object:nil];
}
- (void) keyboardWillShow:(NSNotification *) notif
{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size;
NSLog(@"keyBoard:%f", keyboardSize.height); //216
///keyboardWasShown = YES;
self.frame = CGRectMake(0, self.reply_heigth - keyboardSize.height - self.frame.size.height, SCREEN_WITH, 40);
}
- (void) keyboardWillhiden:(NSNotification *) notif
{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size;
NSLog(@"keyboardWasHidden keyBoard:%f", keyboardSize.height);
// keyboardWasShown = NO;
[UIView animateWithDuration:0.15 animations:^{
self.frame = CGRectMake(0, self.reply_heigth - keyboardSize.height - self.frame.size.height, SCREEN_WITH, 40);
}];
}