码迷,mamicode.com
首页 > 其他好文 > 详细

键盘上附加工具栏

时间:2014-07-09 14:56:17      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:width   os   cti   for   io   size   

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)];

}];

}

 

键盘上附加工具栏,布布扣,bubuko.com

键盘上附加工具栏

标签:width   os   cti   for   io   size   

原文地址:http://www.cnblogs.com/ldc529/p/3832260.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!