[[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的更多相关文章

  1. IOS中键盘隐藏几种方式

    在ios开发中,经常需要输入信息.输入信息有两种方式: UITextField和UITextView.信息输入完成后,需要隐藏键盘,下面为大家介绍几种隐藏键盘的方式. <一> 点击键盘上的 ...

  2. iOS中键盘的收起

    在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法之外,还有另外三种方法: 重载UIViewController中的touchesBegin方 ...

  3. ios中键盘处理源码

      1:先分别设置各个文本框的键盘类型(inputview)-->在特定键盘中textediting中禁用输入. 2:然后递归绑定各个键盘的工具条(inputaccessview).并且个各个控 ...

  4. H5页面IOS中键盘弹出导致点击错位的问题

    IOS在点击输入框弹出键盘  键盘回缩 后 定位没有相应改变  还有  textarea 也会弹出键盘 $("input").blur(function() { console.l ...

  5. 您的位置:首页 » IOS » iOS中全局悬浮按钮,类似IPhone中的AssistiveTouch iOS中全局悬浮按钮,类似IPhone中的AssistiveTouch

    原文地址:http://blog.5ibc.net/p/86562.html 前提:当时看到别人写过这个类似AssistiveTouch的demo,但是有问题,第一改变不了位置.第二切换页面后无法使用 ...

  6. ios 中键盘被遮挡解决方案

    1.当view是非可以滚动的view时, // 添加对键盘的通知 - -(void)viewDidLoad{ [[NSNotificationCenter defaultCenter] addObse ...

  7. ios中键盘处理(二)

    设置UIscrollview的背景代码 - (UIImage *) ImageWithColor: (UIColor *) color frame:(CGRect)aFrame { UIGraphic ...

  8. iOS开发UI篇—iPad和iPhone开发的比较

    一.iPad简介 1.什么是iPad 一款苹果公司于2010年发布的平板电脑 定位介于苹果的智能手机iPhone和笔记本电脑产品之间 跟iPhone一样,搭载的是iOS操作系统 2.iPad的市场情况 ...

  9. iOS 中关闭键盘方法

    在 iOS 程序中当想要在文本框中输入数据,轻触文本框会打开键盘.对于 iPad 程序,其键盘有一个按钮可以用来关闭键盘,但是 iPhone 程序中的键盘却没有这样的按钮,不过我们可以采取一些方法关闭 ...

随机推荐

  1. 如何修改Windows上某块网卡的MTU的值

    先用如下命令查看所有的网卡以及他们的MTU的值. netsh interface ipv4 show interfaces 使用如下的命令修改他们的MTU为9000.        netsh int ...

  2. iOS开发-UINavigationBar和Status Bar实用技巧

    iOS7之后关于UINavigationBar和Status  Bar都发生了一系列的改变,如果不需要兼容iOS7之后的设备,按照网上有些资料去解决问题会踩到一些坑.在iOS 7中,我们可以修改每个V ...

  3. protobuf Protocol Buffers 简介 案例 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  4. cdn网络加速

    CDN全称Content Delivery Network,即内容分发网络.其基本思路是尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输的更快.更稳定.通过在网络各处放置节点服 ...

  5. WINDOWS 逻辑坐标 设备坐标 屏幕坐标 客户区坐标

    转自:http://blog.csdn.net/lovesunshine2008/article/details/4048158 设置坐标映射    (1)Windows坐标系统 Windows坐标系 ...

  6. Android -- Property Animation

    3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中又引入了一个新的动画系统:property animation,这三 ...

  7. 【中文分词系列】 4. 基于双向LSTM的seq2seq字标注

    http://spaces.ac.cn/archives/3924/ 关于字标注法 上一篇文章谈到了分词的字标注法.要注意字标注法是很有潜力的,要不然它也不会在公开测试中取得最优的成绩了.在我看来,字 ...

  8. 图形数据库 Neo4j 开发实战

    https://www.ibm.com/developerworks/cn/java/j-lo-neo4j/ Neo4j 是一个高性能的 NoSQL 图形数据库.Neo4j 使用图(graph)相关的 ...

  9. __attribute__中constructor和destructor[总结]

    1.前言 最近看到一份代码,看到一个函数前面用__attribute__((destructor))修饰,当时感觉有点怪怪的,搜了整个程序,也没发现哪个地方调用这个函数.于是从字面意思猜想,该函数会在 ...

  10. Python在VSCode中进入交互界面调试

    VSCode非常强大,断点好用,美中不足,每次只能通过下面窄窄一行进行各种检查,而python的优点就在于交互式的调试,所以希望能够在断点时能够进入到正常的交互界面进行调试. 我用的插件是: 设置交互 ...