[[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. Go语言之进阶篇简单版并发服务器

    1.简单版并发服务器 示例1: package main import ( "fmt" "net" "strings" ) //处理用户请求 ...

  2. go语言之进阶篇字符串操作常用函数介绍

    下面这些函数来自于strings包,这里介绍一些我平常经常用到的函数,更详细的请参考官方的文档. 一.字符串操作常用函数介绍 1.Contains func Contains(s, substr st ...

  3. iOS蓝牙空中升级(固件升级)

    空中升级又叫固件升级,指你手机从服务器下载下来的包或者数据,通过蓝牙传输给你的外设升级固件.如果你能把蓝牙的基础搞懂,其实也并不是很难,我在这里只不过提供一下思路. 空中升级略难的地方在于数据处理和交 ...

  4. System.Diagnostics.Debug和System.Diagnostics.Trace

    在 .net 类库中有一个 system.diagnostics 命名空间,该命名空间提供了一些与系统进程.事件日志.和性能计数器进行交互的类库.当中包括了两个对开发人员而言十分有用的类——debug ...

  5. C++两个矩阵相乘

    /*编程求两个矩阵相乘的结果.输入第一行是整数m,n,表示第一个矩阵式m行n列的:然后是一个m * n的矩阵.再下一行的输入时整数p,q,表示下一个矩阵p行,q列的(n=p);然后就是一个p行q列的矩 ...

  6. 关于UITableView的黑线条

    这里採用分组形式.底色可用图片覆盖,设置为cell(是一个view)的子视图,并把cell'的颜色设置为底色 当UITableView的cell没有满屏显示时,就会出现黑线条.我们仅仅需在初始化时,加 ...

  7. lstm(一) 演化之路

    递归神经网络引入了时序的反馈机制,在语音.音乐等时序信号的分析上有重要的意义. Hochreiter(应该是Schmidhuber的弟子)在1991年分析了bptt带来的梯度爆炸和消失问题,给学习算法 ...

  8. 简单实现http proxy server怎么实现?

    原文:https://blog.csdn.net/dolphin98629/article/details/54599850 简单实现http proxy server怎么实现?

  9. Simple XOR Encryption/Decryption in C++ (And Several Other Languages)

    For details on how to implement XOR encryption using Go, see this post. If you are looking for XOR e ...

  10. AS打开速度慢,AS项目导入慢,新建项目导入慢

    1.AS打开速度慢 在Android Studio的bin目录里,打开idea.prooperties文件,添加disable.android.first.run=true 再次打开时,启动加快 2. ...