swift 地图应用开发 --- 弹出键盘view上移

<!-- lang: cpp -->

 NSNotificationCenter.defaultCenter().addObserver(self,
        selector: "keyboardWillShowNotification:",
        name: UIKeyboardWillShowNotification,
        object: nil)
    
    NSNotificationCenter.defaultCenter().addObserver(self,
        selector: "keyboardWillHideNotification:",
        name: UIKeyboardWillHideNotification,
        object: nil)


 func keyboardWillShowNotification(notification: NSNotification){
    var info:NSDictionary = notification.userInfo!
    var keyheight = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue().height

    
    var height = keyheight + subview.frame.height
    if(height > self.view.frame.height){

        let n = KeyboardNotification(notification)
        let animationDuration = n.animationDuration
        let animationCurve = n.animationCurve

        
        self.view.layoutIfNeeded()
        UIView.animateWithDuration(animationDuration,
            delay: 0,
            options: UIViewAnimationOptions(rawValue: UInt(animationCurve << 16)),
            animations: {
                self.top.constant = self.view.frame.height - height
                self.view.layoutIfNeeded()
            },
            completion: nil
        )
        
    }
    

    

}

func keyboardWillHideNotification(notification: NSNotification){
    
    let n = KeyboardNotification(notification)
    let animationDuration = n.animationDuration
    let animationCurve = n.animationCurve
    self.view.layoutIfNeeded()
    UIView.animateWithDuration(animationDuration,
        delay: 0,
        options: UIViewAnimationOptions(rawValue: UInt(animationCurve << 16)),
        animations: {
            self.top.constant = 0
            self.view.layoutIfNeeded()
        },
        completion: nil
    )


}

swift 输入字数统计 中文、英文、符号均为一个字符

<!-- lang: cpp -->
 var temp = "";
    for c:Character in alltext {
        
        if((++length) <= 200){
         temp.append(c)
        }
    }

转载于:https://my.oschina.net/u/922864/blog/408022

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值