KeyBoard 在iOS7和iOS8上通知的区别

首先注册通知如下:

NSNotificationCenter.defaultCenter().addObserver(self,
selector: "keyboardWillShow:", name:UIKeyboardWillChangeFrameNotification, object:nil)

通知内容:

func keyboardWillShow(noti:NSNotification){

var userInfo :NSDictionary = noti.userInfo!

var  duration :NSValue =
userInfo["UIKeyboardAnimationDurationUserInfoKey"]asNSValue

var animationDuration :NSTimeInterval!
=0

duration.getValue(&animationDuration)

var keyFrame :NSValue
= userInfo["UIKeyboardFrameEndUserInfoKey"]as
NSValue

var krect = keyFrame.CGRectValue()

}

打印内容如下:

注明:这是iPad横向的时候哦。

iOS7.1:键盘响应,弹起

{

    UIKeyboardAnimationCurveUserInfoKey = 7;

    UIKeyboardAnimationDurationUserInfoKey = "0.25";

    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {1024, 406}}";

    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {512, 971}";

    UIKeyboardCenterEndUserInfoKey = "NSPoint: {512, 565}";

    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{-406, 0}, {406, 1024}}";

    UIKeyboardFrameChangedByUserInteraction = 0;

    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 0}, {406, 1024}}";

}

键盘响应,收回resignFirstResponder

UIKeyboardWillChangeFrameNotification; userInfo = {

UIKeyboardAnimationCurveUserInfoKey = 7;

UIKeyboardAnimationDurationUserInfoKey = "0.25";

UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {1024, 406}}";

UIKeyboardCenterBeginUserInfoKey = "NSPoint: {512, 565}";

UIKeyboardCenterEndUserInfoKey = "NSPoint: {512, 971}";

UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 0}, {406, 1024}}";

UIKeyboardFrameChangedByUserInteraction = 0;

UIKeyboardFrameEndUserInfoKey = "NSRect: {{-406, 0}, {406, 1024}}";

}

iOS8:键盘响应,弹起

{

    UIKeyboardAnimationCurveUserInfoKey = 7;

    UIKeyboardAnimationDurationUserInfoKey = "0.25";

    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {1024, 406}}";

    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {512, 971}";

    UIKeyboardCenterEndUserInfoKey = "NSPoint: {512, 565}";

    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 768}, {1024, 406}}";

    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 362}, {1024, 406}}";

}

键盘响应,收回resignFirstResponder

{

    UIKeyboardAnimationCurveUserInfoKey = 7;

    UIKeyboardAnimationDurationUserInfoKey = "0.25";

    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {1024, 406}}";

    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {512, 565}";

    UIKeyboardCenterEndUserInfoKey = "NSPoint: {512, 971}";

    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 362}, {1024, 406}}";

    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 768}, {1024, 406}}";

}

时间: 2024-08-12 07:17:57

KeyBoard 在iOS7和iOS8上通知的区别的相关文章

本地推送通知在iOS8上的不同

iOS8的不同点 你如果把上面的程序运行在iOS8上,会爆出如下错误 预习01-本地推送通知[掌握][615:7847] Attempting to schedule a local notification {fire date = Monday, July 13, 2015 at 9:02:25 AM China Standard Time, time zone = (null), repeat interval = 0, repeat count = UILocalNotification

(七十五)CoreLocation(一)在iOS7和iOS8设备上获取授权

苹果在iOS8上更新了CoreLocation的授权获取方式,在原来的基础上,不仅需要调用授权函数,还需要对info.plist进行相应的配置. 在iOS上获取经纬度使用的是CoreLocationManager,它来自CoreLocation.framework框架,使用时应当包含框架的总头文件: #import <CoreLocation/CoreLocation.h> 一般是先创建管理者,然后成为其代理,对于iOS7,直接调用startUpdatingLocation即可开始监听,而对于

iOS7、iOS8推送通知的区别

iOS8版本以后的推送通知代码[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];//注意下面这句,在iOS8

ios7与ios8并存,注册推送通知

// IOS8 新系统需要使用新的代码咯 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound |UIUserNotification

iOS7,iOS8和iOS9的区别

iOS7,iOS8和iOS9的区别:iOS7.0 1.iOS 7是iOS面世以来在用户界面上做出改变最大的一个操作系统.iOS 7抛弃了以往的拟物化设计,而采用了扁平化设计. 苹果在重新思考 iOS 的设计时,更希望围绕 iOS 中深受人们喜爱的元素,打造一种更加简单实用而又妙趣横生的用户体验.最终,苹果优化了 iOS 的工作方式,并以此为基础重新设计了 iOS 的外观.之所以这样做,是因为能够服务于体验的设计才是出色的设计. 2.控制中心 控制中心为你建立起快速通路,便于你使用那些随时急需的控

NSMutableAttributing相关 ios7升级ios8出现的问题

项目在ios7上没有问题,但是升级ios8以后,出现了不少问题,其中一个追踪到就是在NSMutableAttributing的使用上出现的问题. 项目中有个功能是:有一串字符串,对指定位置的字符设置不同的颜色,就是使用NSMutableAttributedString来实现的: NSMutableAttributedString *attibuttionStr = [[NSMutableAttributedString alloc] initWithString:str]; [attibutti

iOS8上放大缩小的动画

CGAffineTransformMakeScale这个方法我们以前经常使用,但是在IOS8上出现问题了 [UIView animateWithDuration:0.3 animations:^{ bgView.frame=CGRectMake(0,0-(y/2), WIDTH, HEIGHT); logoImageView.transform=CGAffineTransformMakeScale(0, 0); }]; ios8上面如果是0的话,则会产生突然消失的情况,需要修改代码为0.1才可以

ios7 关于searchbar上设置cancelButton的title属性

通过 [searchBarsetShowsCancelButton:YES];设置之后默认是"cancel",想改为中文的 在stackoverflow上参考了很多方法都没用 这里的关键是要获取到 searchbar中得 cancelButton 通过打印 [searchbar subviews] 得到结果如下 (lldb) po [searchBar subviews] <__NSArrayM 0xd6b0db0>( <UIView: 0xd6aab30; fram

SIS系统和DCS系统的使用与组态上的本质区别分析,更深刻的知道DCS为了控制,SIS为了保护! sis系统和DCS系统有什么区别?

DCS --distribution control system 分散式控制系统,工厂控制级系统,常规数据采集,设备控制都 由此系统完成. SIS--safty instruments system 安全仪表系统,联锁系统的一种,一般做工厂过程设备的安全保护控制,有时也包含机组安全保护控制.sis系统和DCS系统使用上有什么区别? sis系统使用实时平台支持各功能模块在不同的服务器上分布运行,使各服务器的负载均衡,使用不同的网卡分别连接控制系统与SIS系统,保证网络隔离.控制系统的所有数据只能