首页 > 移动平台 > 详细

KeyBoard 在iOS7和iOS8上通知的区别

时间:2015-04-01 11:24:44      阅读:600      评论:0      收藏:0      [点我收藏+]

首先注册通知如下:

            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}}";

}


KeyBoard 在iOS7和iOS8上通知的区别

原文:http://blog.csdn.net/yanyanforest/article/details/44803503

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!