美文网首页
键盘弹出

键盘弹出

作者: 独孤伊人_xie | 来源:发表于2016-07-14 14:21 被阅读24次

    //通知

    funcnotification(){

    NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(HISModifyOrderVC.boardWillShow), name: UIKeyboardWillShowNotification, object:nil)

    NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(HISModifyOrderVC.boardWillHide), name: UIKeyboardWillHideNotification, object:nil)

    }

    //键盘出现

    funcboardWillShow(notification:NSNotification){

    varuserInFo= NSDictionary()

    userInFo = notification.userInfo!

    varHeight = CGFloat()

    Height = (userInFo.objectForKey(UIKeyboardFrameEndUserInfoKey)?.CGRectValue().size.height)!

    tbView.frame = CGRectMake(0,0-Height, CGRectGetWidth(UIScreen.mainScreen().bounds), CGRectGetHeight(UIScreen.mainScreen().bounds)-50)

    }

    //键盘消失

    funcboardWillHide(notification:NSNotification){

    tbView.frame = CGRectMake(0, -30, CGRectGetWidth(UIScreen.mainScreen().bounds), CGRectGetHeight(UIScreen.mainScreen().bounds)-100)

    }

    相关文章

      网友评论

          本文标题:键盘弹出

          本文链接:https://www.haomeiwen.com/subject/lxvejttx.html