- (void)viewDidLoad{
[[NSNotificationCenterdefaultCenter] addObserver:self selector:@selector(keyboardDidShow:)
name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenterdefaultCenter] addObserver:self selector:@selector(keyboardDidHide:)
name:UIKeyboardDidHideNotification object:nil];
}
- (void)keyboardDidShow:(NSNotification *)nsNotification {
NSDictionary *userInfo = [nsNotificationuserInfo];
_keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
[selfupdateTextViewSize];
}
- (void)keyboardDidHide:(NSNotification *)nsNotification {
_keyboardSize =CGSizeMake(0.0,0.0);
[selfupdateTextViewSize];
}
- (void)updateTextViewSize {
UIInterfaceOrientation orientation =
[UIApplication sharedApplication].statusBarOrientation;
CGFloat keyboardHeight = UIInterfaceOrientationIsLandscape(orientation) ? _keyboardSize.width
:_keyboardSize.height;
_textView.frame =CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - keyboardHeight);
}