码迷,mamicode.com
首页 > 移动开发 > 详细

KeyBoard 在iOS7和iOS8上通知的区别

时间:2015-04-01 11:25:58      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:ios7   swift   

首先注册通知如下:

            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上通知的区别

标签:ios7   swift   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!