监听键盘高度实现评论功能
来源:互联网 发布:国家人工智能战略 编辑:程序博客网 时间:2024/04/28 15:19
效果展示:
代码:
//监听键盘出现和消失
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
#pragma mark 键盘出现
-(void)keyboardWillShow:(NSNotification *)note
{
// 这样就拿到了键盘的位置大小信息frame,然后根据frame进行高度处理之类的信息
NSDictionary *info = note.userInfo;
CGRect beginFrame = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
id animationDurationValue = [[note userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration;
[animationDurationValue getValue:&animationDuration];
float time = [animationDurationValue floatValue];
[UIView animateWithDuration:time animations:^{
if (self.commentTF.isFirstResponder && /*解决多次调用的问题,只执行最后一次*/beginFrame.size.height>0 && (beginFrame.origin.y-endFrame.origin.y>0)) {
self.toolView.mj_y = kSH-64-50*kAdaptValue - endFrame.size.height;
}
}];
}
#pragma mark 键盘消失
-(void)keyboardWillHide:(NSNotification *)note
{
if (self.commentTF.isFirstResponder) {
self.toolView.mj_y = kSH-64-50*kAdaptValue;
// flagToolHeight = 1;
}
}
别忘了。。。
-(void)dealloc
{
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
- 监听键盘高度实现评论功能
- Android评论发图功能实现以及软键盘的监听和获得软键盘的高度
- 监听键盘高度
- ios键盘高度监听
- iOS 评论界面 监听键盘高度 动态改变输入框位置
- UIKeyboardWillShowNotification 监听键盘高度变化
- UIKeyboardWillShowNotification 监听键盘高度变化
- 监听键盘高度oc---swfit
- 监听键盘高度变化,以及键盘自定义
- Flex(AS 3.0)实现快捷键功能--监听键盘事件
- ExtJS监听键盘事件:回车键实现登录功能
- iOS 监听键盘高度,监听键盘出现 收回事件
- app 评论功能实现
- 实现评论,回复功能
- JS实现键盘监听
- JS实现键盘监听
- ios 动态监听键盘输入法和高度
- ios 动态监听键盘输入法和高度
- [转]Linux下STM32开发环境的搭建
- sudo和rpm命令
- 【科普】VR视频与全景视频有什么不同?
- java/jsp获取当前时间是本年的第几周
- opencv中读取图像的绝对路径问题
- 监听键盘高度实现评论功能
- 如何解决高版本Google Chrome(谷歌浏览器)扩展程序强制停用问题?或者经常提示停用扩展程序
- STLmap、multimap、unordered_map、unordered_multimap差异
- 服务-dns服务器
- 用二分法求方程的根
- Java EE知识储备(八)
- 查看mysql表的数据大小和索引大小
- 一个开源中国牛人的博客(对于Mybatis)
- CodeForces 644 A.Parliament of Berland(构造)