ios-利用键盘通知处理键盘出现时遮挡控件问题
-(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-利用键盘通知处理键盘出现时遮挡控件问题的更多相关文章
- [Swift]键盘遮挡控件
键盘遮挡控件: super.viewDidLoad(){ // Do any additional setup after loading the view, typically from a nib ...
- 键盘遮挡控件(textfield/textview.......)
采用的是通知的常规方式 // 解决键盘遮挡问题//选择didShow是因为需要键盘的高度//选择willHide是因为视图frame重置需要优先于键盘消失,否则表现得不连贯 [[NSNotificat ...
- iOS开发UI篇—Date Picker和UITool Bar控件简单介绍
iOS开发UI篇—Date Picker和UITool Bar控件简单介绍 一.Date Picker控件 1.简单介绍: Date Picker显示时间的控件 有默认宽高,不用设置数据源和代理 如何 ...
- iOS 9应用开发教程之使用开关滑块控件以及滚动部署视图
iOS 9应用开发教程之使用开关滑块控件以及滚动部署视图 使用ios9中的开关.滑块控件 开关和滑块也是用于和用户进行交互的控件.本节将主要讲解这两种控件. ios9开关 开关控件常用来控制某个功能的 ...
- asp.net 弹出式日历控件 选择日期 Calendar控件
原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...
- dragView 屏幕拖拽并且弹出菜单的控件
dragView 因项目新需求需要添加一个屏幕拖拽按钮可以弹出菜单的控件,因为不是我做的闲来无事写一个demo吧 可能存在一些小bug(毕竟就写了几个小时)兄弟姐妹们理解思路就行 具体的可以自己调试一 ...
- IOS开发-键盘通知自定义键盘
利用键盘通知可实现效果如下: 1.UIKeyboardWillShowNotification: 当点击到可输入的控件上(一般是UITextField)时,键盘会自动显示,并且触发UIKeyboard ...
- 利用ArcGIS Engine、VS .NET和Windows控件开发GIS应用
Dixon 原文 用ArcGIS Engine.VS .NET和Windows控件开发GIS应用 此过程说明适合那些使用.NET建立和部署应用的开发者,它描述了使用ArcGIS控件建立和部署 ...
- iOS项目开发实战——使用Xcode6设计自己定义控件与图形
在iOS开发中,有很多控件都是Xcode默认提供的.使用这些控件是很方便的.可是因为某些须要.须要自己设计控件,那么应该怎么做呢?在Xcode6中提供了这种接口,同意开发人员高速开发自己定义控件,而且 ...
随机推荐
- Windows Phone 8.1 FilePicker API
在 Windows Phone 8.1 中,增加了 FilePicker 的方式与文件打交道,最大的亮点在于这种方式不仅可以浏览手机上的文件,还可以浏览符合协议的应用里的文件! 比如点击 OneDri ...
- [Linux] Search the contents of files using grep
Learn the basic syntax for using grep to search the contents of a single file or files. It's like CM ...
- php 获取提交来源,判断从哪里提交的
echo $_SERVER['HTTP_REFERER'];这个获取上个页面的url例如获得的是 $url = http://www.weisuyun.com/nihao.html其他页面提交过来的不 ...
- zzuli OJ 1128: 课程平均分
Description 期末考试结束,班主任拿到了本班学生的成绩汇总表.由m行n列组成(本班共同拥有m名学生,本学期有n门课程),每行是一个同学的n门课程成绩,请编敲代码,计算并输出每门课的平均分.结 ...
- [GraphQL] Add an Interface to a GraphQL Schema
As we start building out more complex GraphQL schemas, certain fields start to repeat across differe ...
- 【iOS】怎样推断文本文件的字符编码格式
整体思路: 遍历全部的字符编码.能正确读取输出转换的就是文本文件的编码格式. 代码例如以下: // // main.m // 检測文本字符编码格式的小技巧 // // Created by 杜子兮 ( ...
- 【计算机视觉】OpenCV中直方图处理函数简述
计算直方图calcHist 直方图是对数据集合的统计 ,并将统计结果分布于一系列提前定义的bins中.这里的数据不只指的是灰度值 ,统计数据可能是不论什么能有效描写叙述图像的特征. 如果有一个矩阵包括 ...
- 5.7-基于Binlog+Position的复制搭建
基本环境 Master Slave MySQL版本 MySQL-5.7.16-X86_64 MySQL-5.7.16-X86_64 IP 192.168.56.156 192.168.56.157 ...
- 通过binlog日志统计dml语句,找出操作频繁的表
mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.000002 |awk '/###/{if($0~/UPDA ...
- [Angular] Dynamic component's instance and sorting
After create a component dynamic, we are able to change the component's props and listen to its even ...