-(void)viewDidLoad {
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; //注册键盘显示通知
[center addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; //注册键盘隐藏通知
[center addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
} -(void)viewDidDisappear:(BOOL)animated
{ //移除通知
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
} - (void) keyboardWillShow:(NSNotification *) notification{ NSDictionary *info;
CGSize kbSize;
double kbheight;
CGFloat Oversize;
double duraction; info = notification.userInfo;
kbSize = [[info objectForKey: UIKeyboardFrameEndUserInfoKey]
CGRectValue].size;
kbheight = kbSize.height; Oversize = (self.view.frame.size.height - kbheight) - (textfield.frame.origin.y + textfield.frame.size.height+); duraction = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; if (Oversize < ){
[UIView animateWithDuration: duraction animations:^{
self.view.frame = CGRectMake(0.0f, Oversize, self.view.frame.size.width, self.view.frame.size.height);
}];
}
} -(void) keyboardWillHide:(NSNotification *) notification{ double duraction = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; [UIView animateWithDuration:duraction animations:^{
self.view.frame = CGRectMake(, , self.view.frame.size.width, self.view.frame.size.height);
}];
}

ios-利用键盘通知处理键盘出现时遮挡控件问题的更多相关文章

  1. [Swift]键盘遮挡控件

    键盘遮挡控件: super.viewDidLoad(){ // Do any additional setup after loading the view, typically from a nib ...

  2. 键盘遮挡控件(textfield/textview.......)

    采用的是通知的常规方式 // 解决键盘遮挡问题//选择didShow是因为需要键盘的高度//选择willHide是因为视图frame重置需要优先于键盘消失,否则表现得不连贯 [[NSNotificat ...

  3. iOS开发UI篇—Date Picker和UITool Bar控件简单介绍

    iOS开发UI篇—Date Picker和UITool Bar控件简单介绍 一.Date Picker控件 1.简单介绍: Date Picker显示时间的控件 有默认宽高,不用设置数据源和代理 如何 ...

  4. iOS 9应用开发教程之使用开关滑块控件以及滚动部署视图

    iOS 9应用开发教程之使用开关滑块控件以及滚动部署视图 使用ios9中的开关.滑块控件 开关和滑块也是用于和用户进行交互的控件.本节将主要讲解这两种控件. ios9开关 开关控件常用来控制某个功能的 ...

  5. asp.net 弹出式日历控件 选择日期 Calendar控件

    原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...

  6. dragView 屏幕拖拽并且弹出菜单的控件

    dragView 因项目新需求需要添加一个屏幕拖拽按钮可以弹出菜单的控件,因为不是我做的闲来无事写一个demo吧 可能存在一些小bug(毕竟就写了几个小时)兄弟姐妹们理解思路就行 具体的可以自己调试一 ...

  7. IOS开发-键盘通知自定义键盘

    利用键盘通知可实现效果如下: 1.UIKeyboardWillShowNotification: 当点击到可输入的控件上(一般是UITextField)时,键盘会自动显示,并且触发UIKeyboard ...

  8. 利用ArcGIS Engine、VS .NET和Windows控件开发GIS应用

    Dixon 原文  用ArcGIS Engine.VS .NET和Windows控件开发GIS应用     此过程说明适合那些使用.NET建立和部署应用的开发者,它描述了使用ArcGIS控件建立和部署 ...

  9. iOS项目开发实战——使用Xcode6设计自己定义控件与图形

    在iOS开发中,有很多控件都是Xcode默认提供的.使用这些控件是很方便的.可是因为某些须要.须要自己设计控件,那么应该怎么做呢?在Xcode6中提供了这种接口,同意开发人员高速开发自己定义控件,而且 ...

随机推荐

  1. 什么是网站CDN服务,CDN加速原理?

    转载:http://server.zzidc.com/fwqcjwt/728.html 摘要:在为您的网站打开速度发愁吗?您有没有发现有些大网站每天拥有几十万或者上百万,甚至几亿用户的访问,而且不同用 ...

  2. Android屏幕信息获取

    Android中有时需要获取屏幕的size信息以便对控件位置进行动态控制,最近做了一些研究,现在将获取屏幕大小信息的方法总结如下,可能存在一些地方理解的不全面. 1.getMetrics Displa ...

  3. POJ2112 Optimal Milking 【最大流+二分】

    Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 12482   Accepted: 4508 ...

  4. [Angular] Adding keyboard events to our control value accessor component

    One of the most important thing when building custom form component is adding accessbility support. ...

  5. [React] Use Jest's Snapshot Testing Feature

    Often when testing, you use the actual result to create your assertion and have to manually update i ...

  6. .netcore consul实现服务注册与发现-单节点部署

    原文:.netcore consul实现服务注册与发现-单节点部署 一.Consul的基础介绍     Consul是HashiCorp公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分 ...

  7. 简洁常用权限系统的设计与实现(一):构造权限菜单树的N(N>=4)种方法

    权限系统,Web开发常见标准子系统之一.结合自己的一些思考和实践,从本篇开始权限系统的设计与实现之路. 最近,重构了项目的权限菜单构造过程,向前端返回json格式的权限树. 这一篇,只是大致介绍下这个 ...

  8. 利用SendMessage实现窗口拖动

    原文:利用SendMessage实现窗口拖动 利用SendMessage实现窗口拖动                                            周银辉 想想以前用跟踪鼠标位 ...

  9. 课后作业11--使用SQL语句创建一个数据库

    use master if db_id ('test') is not null--判断test数据库是否存在 drop database [test]--如果存在 删除test go--完成查找删除 ...

  10. 【BZOJ 1034】[ZJOI2008]泡泡堂BNB

    [题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1034 [题意] [题解] 如果己方最小的大于对方最小的(严格大于) 或己方最大的大于对 ...