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"& ...
随机推荐
- [转]用jpa创建web项目,报错:No persistence units parsed from {classpath*:META-INF/persistence.xml}
原文地址:http://blog.sina.com.cn/s/blog_6826662b01015opk.html 最近做一个web项目用到了Spring+JPA,由于没有正确配置persistenc ...
- judge remote file exist
# -*- coding:utf-8 -*- import paramiko,os,sys,time print ''' *****判断远端服务器上的某个文件是否存在***** ''' ip = ra ...
- java -日期
package com.qinghuainvest.tsmarket.util; import java.text.ParseException; import java.text.SimpleDat ...
- GraphX 的属性图
package main.scala import org.apache.spark.graphx.{Edge, Graph, VertexId} import org.apache.spark.rd ...
- js-JavaScript高级程序设计学习笔记11
依然第十四章 1.选择部分文本:使用setSelectionRange()方法,两个参数为第一个字符的索引和最后一个字符之后的索引,类似于substring()方法. 2.IE8及更早版本使用范围选择 ...
- 【BZOJ-4353】Play with tree 树链剖分
4353: Play with tree Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 31 Solved: 19[Submit][Status][ ...
- 【BZOJ-1576】安全路径Travel Dijkstra + 并查集
1576: [Usaco2009 Jan]安全路经Travel Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1044 Solved: 363[Sub ...
- 数论专项测试——约数个数和(lucas的数论)
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- TortoiseGit与GitHub项目关联设置
一.常规克隆GitHub上的项目: 1.在本地硬盘上放置项目的地方上[右键]->[Git 克隆]->在[url地址]上输入https的GitHub的链接,然后就是等待完成,之后即可完成拉取 ...
- dedecms /member/mtypes.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Dedecms会员中心注入漏洞 Relevant Link http:/ ...