- (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 ;
[ self updateTextViewSize];
}
- (void)keyboardDidHide:(NSNotification *)nsNotification {
_keyboardSize =CGSizeMake(0.0,0.0);
[ self updateTextViewSize];
}
- (void)updateTextViewSize {
UIInterfaceOrientation orientation =
[UIApplicationsharedApplication].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);
}
原文:http://blog.csdn.net/leochang130731/article/details/22874263
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!