ios中键盘处理适合ipad 和iphone
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasHidden:)
name:UIKeyboardDidHideNotification object:nil]; =======
-(void)keyboardWasShown:(NSNotification*)aNotification{ NSDictionary *info=[aNotification userInfo]; CGRect KeyBoardrect=[info[UIKeyboardBoundsUserInfoKey] CGRectValue];
int curve=[info[UIKeyboardAnimationCurveUserInfoKey] intValue];
CGFloat duration=[info[UIKeyboardAnimationDurationUserInfoKey] floatValue];
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView *firstResponder = [keyWindow performSelector:@selector(firstResponder)];
if ([NSStringFromClass([firstResponder class]) isEqualToString:@"UITextView"]) { CGFloat height=self.view.bounds.size.height;//view的高度
CGFloat y=self.remarksTextView.frame.origin.y+KHeight;//文本框的高度
CGFloat keyboardheight=KeyBoardrect.size.height+;//键盘高度--》中文高度44
CGFloat h=height-y-keyboardheight;
NSLog(@"%@--keyboard->",info);
NSLog(@"height=%f-- -->",height); if(h<){
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:curve];
[UIView setAnimationDuration:duration];
CGRect rect=self.view.frame;
rect.origin.y+=h;
self.view.frame=rect;
[UIView commitAnimations];
}
}
} -(void) keyboardWasHidden:(NSNotification*)aNotification
{
NSDictionary *info=[aNotification userInfo]; int curve=[info[UIKeyboardAnimationCurveUserInfoKey] intValue];
CGFloat duration=[info[UIKeyboardAnimationDurationUserInfoKey] floatValue]; [UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:curve];
[UIView setAnimationDuration:duration];
self.view.frame=_lastRect;
[UIView commitAnimations]; }
ios中键盘处理适合ipad 和iphone的更多相关文章
- IOS中键盘隐藏几种方式
在ios开发中,经常需要输入信息.输入信息有两种方式: UITextField和UITextView.信息输入完成后,需要隐藏键盘,下面为大家介绍几种隐藏键盘的方式. <一> 点击键盘上的 ...
- iOS中键盘的收起
在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法之外,还有另外三种方法: 重载UIViewController中的touchesBegin方 ...
- ios中键盘处理源码
1:先分别设置各个文本框的键盘类型(inputview)-->在特定键盘中textediting中禁用输入. 2:然后递归绑定各个键盘的工具条(inputaccessview).并且个各个控 ...
- H5页面IOS中键盘弹出导致点击错位的问题
IOS在点击输入框弹出键盘 键盘回缩 后 定位没有相应改变 还有 textarea 也会弹出键盘 $("input").blur(function() { console.l ...
- 您的位置:首页 » IOS » iOS中全局悬浮按钮,类似IPhone中的AssistiveTouch iOS中全局悬浮按钮,类似IPhone中的AssistiveTouch
原文地址:http://blog.5ibc.net/p/86562.html 前提:当时看到别人写过这个类似AssistiveTouch的demo,但是有问题,第一改变不了位置.第二切换页面后无法使用 ...
- ios 中键盘被遮挡解决方案
1.当view是非可以滚动的view时, // 添加对键盘的通知 - -(void)viewDidLoad{ [[NSNotificationCenter defaultCenter] addObse ...
- ios中键盘处理(二)
设置UIscrollview的背景代码 - (UIImage *) ImageWithColor: (UIColor *) color frame:(CGRect)aFrame { UIGraphic ...
- iOS开发UI篇—iPad和iPhone开发的比较
一.iPad简介 1.什么是iPad 一款苹果公司于2010年发布的平板电脑 定位介于苹果的智能手机iPhone和笔记本电脑产品之间 跟iPhone一样,搭载的是iOS操作系统 2.iPad的市场情况 ...
- iOS 中关闭键盘方法
在 iOS 程序中当想要在文本框中输入数据,轻触文本框会打开键盘.对于 iPad 程序,其键盘有一个按钮可以用来关闭键盘,但是 iPhone 程序中的键盘却没有这样的按钮,不过我们可以采取一些方法关闭 ...
随机推荐
- 如何在Windows版的ScaleIO的节点中添加磁盘
嗯, 为什么会有这个问题呢? 因为我要安装ScaleIO 1.32, 在使用Installation manager完成初始安装之后, 需要将一些磁盘添加到ScaleIO的storage pool中. ...
- 重启Windows的PowerShell
这么简单的一个命令都单独写一篇blog, 是不是太无耻了? 好吧, 谁让咱不会呢. 学会了就来一篇. 呵呵. Restart-Computer 来源 ================ http:/ ...
- JavaScript递归方法 生成 json tree 树形结构数据
//递归方法 生成 json tree 数据 var getJsonTree = function(data, parentId) { var itemArr = []; for (var i = 0 ...
- Ubuntu SVN安装&使用&命令
SVN 安装 apt-get install subversion checkout svn checkout svn://192.168.1.110/app 按提示输入相应的用户名和密码. 往版本库 ...
- NLP领域的ImageNet时代到来:词嵌入「已死」,语言模型当立
http://3g.163.com/all/article/DM995J240511AQHO.html 选自the Gradient 作者:Sebastian Ruder 机器之心编译 计算机视觉领域 ...
- 转:PCA的Python实现
http://blog.csdn.net/jerr__y/article/details/53188573 本文主要参考下面的文章,文中的代码基本是把第二篇文章的代码手写实现了一下. - pca讲解: ...
- Web项目MySQL配置文件运维
root@mysqltest:/etc/mysql/mysql.conf.d# cat mysqld.cnf # # The MySQL database server configuration f ...
- 如何屏蔽ctrl + v 粘贴事件,鼠标右键粘贴事件
通常在自己的APP里的密码框,验证码框需要屏蔽复制,粘贴,怎么办呢? 有三种方法: 1 hook 此方法是最完全的,但由于hook是全局的,容易影响到其它代码. 2 子类化文本框, 重写OnPaste ...
- 开源的DirectUI界面库
1. duilib简介 duilib是一个开源的DirectUI界面库,简洁但是功能强大.而且还是BSD的license,所以即便是在商业上,大家也可以安心使用.现在大家可以从这个网站获取到他们所有的 ...
- Mac 隐私与安全没有允许任何来源选项
mac 允许任何来源的 app 在 macOS Sierra 10.12 及之后的版本,都没有 打开任何来源 的选项,解决方法: 终端执行命令: sudo spctl --master-disable