监听键盘的弹出,让整个页面向上移动,比较简单,仅做记录使用:

代码如下:

 // 监听键盘
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowAction:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHideAction:) name:UIKeyboardWillHideNotification object:nil];

键盘处理:

#pragma mark - 键盘处理

/**
* 键盘即将隐藏
*/
- (void)keyboardWillHideAction:(NSNotification *)note
{ // 1.键盘弹出需要的时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 2.动画
[UIView animateWithDuration:duration animations:^{
self.view.transform = CGAffineTransformIdentity;
}];
} /**
* 键盘即将弹出
*/
- (void)keyboardWillShowAction:(NSNotification *)note
{ // 1.键盘弹出需要的时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 2.动画
[UIView animateWithDuration:duration animations:^{
// 取出键盘高度
CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat keyboardH = keyboardF.size.height - ;
if (_ThreeInch) {
self.view.transform = CGAffineTransformMakeTranslation(, - keyboardH);
} else {
self.view.transform = CGAffineTransformMakeTranslation(, - );
}
}];
}

最新文章

  1. MySQL线程独享[转]
  2. STM32F4_USART配置及细节描述
  3. 自己制作 SPx N合1 自动安装盘(x86)
  4. 微软阵营企稳的利好消息:.NET开源、Visual Studio免费
  5. Linux下搭建tomcat集群全记录(转)
  6. A/B测试评测
  7. [原]vue实现全选,反选
  8. [.net 面向对象程序设计深入](18)实战设计模式——设计模式使用场景及原则
  9. Docker Toolbox
  10. Hibernate中get()和load()方法区别
  11. 第二节,神经网络中反向传播四个基本公式证明——BackPropagation
  12. 初识ActiveMQ
  13. 类Shiro权限校验框架的设计和实现(2)--对复杂权限表达式的支持
  14. 18.1 volatile的作用
  15. bash:express:command not found
  16. C++.构造函数(超出范围)_01
  17. (五)使用GitHub的前期准备
  18. Logstash之四:logstash接收kafka数据
  19. nginx反向代理部署与演示(二)
  20. win10不能被远程解决方案(开启远程桌面,防火墙仍不能被远程解决方案)

热门文章

  1. centos下 安装jdk
  2. BZOJ 1603 [Usaco2008 Oct]打谷机 dfs
  3. hook NtReadVirtualMemory干扰杀软扫描
  4. javascript异步代码的回调地狱以及JQuery.deferred提供的promise解决方式
  5. atitit.attilax.com产品 软件项目通用框架类库总结
  6. atitit.自己动手开发编译器and解释器(1) ------词法分析--attilax总结
  7. AppModify修改app.config
  8. 我的高效编程的秘诀--开发环境的重要性(IOS)
  9. 每日英语:China Targets Big Pharma
  10. 0061 Spring MVC的数据格式化--Formatter--FormatterRegistrar--@DateTimeFormat--@NumberFormat