uitableview 关于键盘挡住输入框解决方法
//
// AboutKeyBoardEventViewController.m
// QueryBussinessInfo
//
// Created by mac on 16/8/23.
// Copyright © 2016年 cqytjr. All rights reserved.
// #import "AboutKeyBoardEventViewController.h" @interface AboutKeyBoardEventViewController () @end @implementation AboutKeyBoardEventViewController - (void)viewDidLoad {
[super viewDidLoad];
self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds];
[self.view addSubview:self.tableView];
//监听键盘弹出事件
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
//监听键盘隐藏事件
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
} -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
return nil;
} #pragma mark - 键盘即将弹出事件处理
- (void)keyboardWillShow:(NSNotification *)notification
{
//获取键盘信息
NSDictionary *keyBoardInfo = [notification userInfo]; //获取动画时间
CGFloat duration = [[keyBoardInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; //获取键盘的frame信息
NSValue *value = [keyBoardInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size; [UIView animateWithDuration:duration animations:^{
// CGRect frame = _chatBar.frame;
// frame.origin.y = SCREENHEIGHT - keyboardSize.height - frame.size.height;
// _chatBar.frame = frame;
CGRect rect = self.tableView.frame;
rect.size.height = keyboardSize.height;
self.tableView.frame = rect; } completion:nil];
}
#pragma mark - 键盘即将隐藏事件
- (void)keyboardWillHide:(NSNotification *)notification
{ //获取键盘信息
NSDictionary *keyBoardInfo = [notification userInfo]; //获取动画时间
CGFloat duration = [[keyBoardInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; //获取键盘的frame信息 [UIView animateWithDuration:duration animations:^{ CGRect rect = self.tableView.frame;
rect.size.height = self.view.bounds.size.height;
self.tableView.frame = rect;
} completion:nil];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
uitableview 关于键盘挡住输入框解决方法的更多相关文章
- Android各种键盘挡住输入框解决办法
方法一:windowSoftInputMode:adjustResize和adjustPan 主要实现方法:在 AndroidManifest.xml 对应的Activity里添加 android:w ...
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
https://blog.csdn.net/smileiam/article/details/69055963
- iOS 解决键盘挡住输入框的问题
iOS开发中经常会用到输入框UITextField,所以也常会遇到键盘挡住输入框而看不到输入框的内容. 在这里记录一种方法,用UITextField的代理来实现View的上移来解决这个问题. 首先设置 ...
- 【转】iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
iOS上面对键盘的处理很不人性化,所以这些功能都需要自己来实现, 首先是点击return和屏幕隐藏键盘 这个首先引用双子座的博客 http://my.oschina.net/plumsoft/blog ...
- h5软键盘挡住输入框问题解决(android)
问题 移动端浏览器中的表单在部分android机型上测试,点击靠下的输入框时会遇到弹出的软键盘挡住输入框问题 ios可自身弹起(ios自身的调整偶尔也会出问题,例如第三方键盘会遮挡,原因是第三方输入法 ...
- 【土旦】vue 解决ios H5底部输入框 获取焦点时弹出虚拟键盘挡住输入框 以及监听键盘收起事件
问题描述 im聊天H5页面,在iOS系统下,inpu获取焦点弹出系统虚拟键盘时,会出现挡住input的情况,十分影响用户体验. bug图 解决方法: html: <input type=&quo ...
- Android爬坑之旅:软键盘挡住输入框问题的终极解决方案
前言 开发做得久了,总免不了会遇到各种坑.而在Android开发的路上,『软键盘挡住了输入框』这个坑,可谓是一个旷日持久的巨坑--来来来,我们慢慢看. 入门篇 Base 最基本的情况,如图所示:在页面 ...
- Android WebView 软键盘挡住输入框
解决方法一: 在所在的Activity中加入 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RES ...
- ubuntu桌面右上角键盘图标不见解决方法
今天出现了这个问题,桌面右上角的键盘图标不见,找到解决方法如下: 打开终端,分别输入以下命令即可: killall ibus-daemon 这个表示结束进程 ibus-daemon -d 这个表示重启 ...
随机推荐
- NEUQ1055谭浩强C语言(第三版)习题6.11
//迭代公式不是很理解,写出来算了.. #include <stdio.h> #include <math.h> int main() { double x0,x1; int ...
- F9 开发之左树右表中的左树
1 首先在前端应用树树控件 <div class="fui-left"> <div role="head" title="地区选择& ...
- matlab,xls转换为mat文件
b=xlsread('iris_data.xls');save iris_data.mat b
- spark MLLib的基础统计部分学习
参考学习链接:http://www.itnose.net/detail/6269425.html 机器学习相关算法,建议初学者去看看斯坦福的机器学习课程视频:http://open.163.com/s ...
- dict字典学习笔记
dict的创建: #第一行初始化指定一个dict d = {'1':'刘刚','2':李萌,'3':89} #key在前,value在后.key ...
- 从补丁到POC CVE-2015-0003(2015.3)
从补丁到POC CVE-2015-0003 1. 简介 该漏洞是由于Windows的win32k.sys模块存在对用户层参数验证不完全,导致存在空指针解引用(Null Pointer Derefere ...
- redhat nginx 启动脚本
#!/bin/sh # # nginx - this script starts and stops the nginx daemin # # chkconfig: - 85 15 # descrip ...
- Python--三元运算与lambda表达式
三元运算: if 1 ==1: name = 'Tim' else: name = 'SB' 利用三元运算来完成上述4句语句任务: name = 'Tim' if 1==1 else 'SB' lam ...
- js、jquery对节点的操作(增、删)
js对节点的操作方法 一.获取 1.父节点的获取 某节点的parentNode属性值即为该节点的父节点.示例: var parent = document.getElementById("o ...
- ios隐藏软键盘
//判断是否为苹果 var isIPHONE = navigator.userAgent.toUpperCase().indexOf('IPHONE')!= -1; // 元素失去焦点隐藏iphone ...