iOS监听键盘事件
#pragma mark - view life cycle
- (void)viewDidLoad {
[super viewDidLoad]; [[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
{ // 1.取出键盘的高度
CGRect temp = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat height = temp.size.height;
// 2.让工具条向上平移
// 2.1取出键盘弹出的动画时间
NSTimeInterval timte = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:timte delay: options: << animations:^{
self.bottomBar.transform = CGAffineTransformMakeTranslation(, -height);
} completion:nil]; }
/**
* 键盘隐藏
*/
- (void)keyboardWillHide:(NSNotification *)note
{
// 2.1取出键盘弹出的动画时间
NSTimeInterval timte = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 清空transform
[UIView animateWithDuration:timte delay: options: << animations:^{ self.bottomBar.transform = CGAffineTransformIdentity;
} completion:nil]; }
iOS监听键盘事件的更多相关文章
- js监听键盘事件
用JS监听键盘按下事件(keydown event) 1.监听全局键盘按下事件,例如监听全局回车事件 1 $(document).keydown(function(event){ 2 if(eve ...
- iOS 监听键盘高度,输入框上升
//设置输入框 ---<因为输入框用了get方法,所以第一次调用输入框要用self 调用>: self.textlab.frame=CGRectMake(, , , ); _textlab ...
- python 监听键盘事件pyHook
#coding=utf- import pyHook import pythoncom # 监听到鼠标事件调用 def onMouseEvent(event): if(event.MessageNam ...
- vue如何监听键盘事件中的按键?
原文地址 背景 在一些搜索框中,我们往往需要监听键盘的按下(onkeydown)或抬起(onkeyup)事件以进行一些操作.在原生js或者jQuery中,我们需要判断e.keyCode的值来获取用户所 ...
- 一、python小功能记录——监听键盘事件
1.监听键盘按键 from pynput.keyboard import Listener def press(key): print(key.char) with Listener(on_press ...
- IOS 监听键盘的通知(NSNotificationCenter)
通知方法: /** * 当键盘改变了frame(位置和尺寸)的时候调用 */ - (void)keyboardWillChangeFrame:(NSNotification *)note { // 设 ...
- jQuery监听键盘事件及相关操作使用教程
一.首先需要知道的是: 1.keydown() keydown事件会在键盘按下时触发. 2.keyup() keyup事件会在按键释放时触发,也就是你按下键盘起来后的事件 3.keypress() k ...
- jQuery监听键盘事件及相关操作使用
一.首先需要知道的是: 1.keydown() keydown事件会在键盘按下时触发. 2.keyup() keyup事件会在按键释放时触发,也就是你按下键盘起来后的事件 3.keypress() k ...
- js和jquery实现监听键盘事件
一.使用javascript实现 <!DOCTYPE html> <html> <head> <meta charset="utf-8"& ...
随机推荐
- 如何在移动端app中应用字体图标icon fonts (转)
原文: http://www.cnblogs.com/willian/p/4166757.html?utm_source=tuicool&utm_medium=referral How to ...
- hdu3572 最大流
Task Schedule Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- Echarts-画堆积柱状图
导入echarts包 <script src='../scripts/libraries/echarts/echarts-all.js'></script> 堆积图js $(f ...
- asp.net mvc 缓存
webConfig 里面配置缓存时间 <caching> <outputCacheSettings> <outputCacheProfiles> <add n ...
- threading示例
多线程举例: import time import threading def worker(): print ("hello.Kamil") time.sleep(1)#等待一秒 ...
- 75.Android之基本架构
转载:http://www.cnblogs.com/lijunamneg/archive/2013/01/18/2866953.html Android其本质就是在标准的Linux系统上增加了Java ...
- 70.Android开发知识点总结
转载:http://blog.csdn.net/worst_hacker/article/details/49867043 1.android之wifi开发 http://blog.csdn. ...
- Noip2016のmengbier
Day0 上午10点多上了火车,向三位学长问了一路去年noip他们是用什么心态去考的,明明老师和同学都说我正常发挥应该没什么问题但心里就是紧张的不行,就是害怕犯个sb错误爆上一道题TAT. 去试机.. ...
- java integer对象判断两个数字是否相等
java integer对象判断两个数字是否相等,不一定对 问题发生的背景:javaweb的项目,起先,因为在java中实体类中的int类型在对象初始化之后会给int类型的数据默认赋值为0,这样在很多 ...
- 一款可以下拉搜索html下拉框控件
直接上图,组件不错,支持静态和动态搜索,这个只是在原控件上自己修改样式后的,这里主要记录一下,在修改别人控件时,应该如何去封装代码: 原控件:http://ivaynberg.github.com/s ...