[[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. iOS开发--知识点总结

    1 .全局变量,变量名前加下划线.和系统一致. 2 . nil指针为空   @“”字符串为空 (内容为空)       ==  判断内存地址   基本变量    对于一些基本类型 可以使用==来判断, ...

  2. ios开发第三方库--cocoapods安装

    1. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quo ...

  3. art虚拟机介绍

    Android 4.4提供了一种与Dalvik截然不同的运行环境ART(Android runtime)支持,ART源于google收购的Flexycore的公司.ART模式与Dalvik模式最大的不 ...

  4. JPA(四):EntityManager

    Persistence Persistence类使用于获取EntityManagerFactory实例,该类包含一个名为createEntityManagerFactory的静态方法. // 创建En ...

  5. FireDAC中的SQLite(二)

    我们接下来将要使用FDDemo.sdb数据库进行访问,开始我们的第一个SQLite访问例子. 我们的FDDemo.sdb存放目录在:C:\Program Files (x86)\Embarcadero ...

  6. mysql游标的使用 No data - zero rows fetched, selected

    转自:http://blog.sina.com.cn/s/blog_544c72960101bvl3.html 这是一个游标的使用例子. 但是其中有几点需要注意,就是为什么要加入 declare CO ...

  7. Python爬虫学习系列教程

    最近想学一下Python爬虫与检索相关的知识,在网上看到这个教程,觉得挺不错的,分享给大家. 来源:http://cuiqingcai.com/1052.html 一.Python入门 1. Pyth ...

  8. 老周发布 UWP 应用的隐私策略(通用)

    UWP 应用隐私策略 前注  本声明通用于老周所发布的所有 UWP 应用,下文简称“应用”.开发者全称:周家安,下文简称“老周”. 1.免责声明 您在使用应用过程中,请遵守<中华人民共和国宪法& ...

  9. Want to write a book? Use word count to stay on track

    http://paloalto.patch.com/groups/maria-murnanes-blog/p/bp--want-to-write-a-book-use-word-count-to-st ...

  10. vSphere Replication:虚拟机的保护伞

    http://server.zdnet.com.cn/server/2013/0401/2151318.shtml ZDNet至顶网服务器频道 04月01日 新闻消息: 保护IT环境的一个基本方面就是 ...