键盘上附加工具栏
m_listView:textview在tableview上,同時需要修改tableview高度?
?
//注冊觀察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboarWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboarWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
?
//顯示附加工具欄
-(void)keyboarWillShow:(NSNotification*)obj{
//獲取鍵盤的高度
? ? NSDictionary *userInfo = [obj userInfo];
? ? NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
? ? CGRect keyboardRect = [aValue CGRectValue];
? ? int height = keyboardRect.size.height;
?
[UIView animateWithDuration:0.2f animations:^(){
[m_listView setFrame:CGRectMake(0, [Utility getNavBarHight], ScreenWidth, ScreenHeight - [Utility getNavBarHight] - 50 - height)];
[menuView setFrame:CGRectMake(0, ScreenHeight - 50-height, m_listView.frame.size.width, 50)];
}];
[m_listView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:m_listView.curText.tag inSection:0] atScrollPosition:UITableViewScrollPositionNone animated:YES];
}
?
-(void)keyboardWillBeHidden:(NSNotification*)obj{
[UIView animateWithDuration:0.3f animations:^(){
[m_listView setFrame:CGRectMake(0, [Utility getNavBarHight], ScreenWidth, ScreenHeight - [Utility getNavBarHight] - 50)];
[menuView setFrame:CGRectMake(0, m_listView.frame.origin.y+ m_listView.frame.size.height, m_listView.frame.size.width, 50)];
}];
}
?
轉載于:https://www.cnblogs.com/ldc529/p/3832260.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
- 上一篇: hibernate二级缓存理解
- 下一篇: android internet参数传递