簡體   English   中英

快捷鍵盤高度返回0

[英]Swift keyboard Height return 0

單擊按鈕時,我的代碼第一次運行正常,但我得到了鍵盤的高度,但問題是當它退出時又再次調用它,它返回hight 0,這是代碼的幫助

@IBAction func showCaseProgressSliderBtn(_ sender: Any){
    NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil)

}

@objc func keyboardWillShow(notification: NSNotification) {
    if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
        let keyboardHeight = keyboardSize.height
        keyboardHeightCG = keyboardHeight
        print("keyboard is \(keyboardHeightCG)")
    }
}

UIKeyboardFrameEndUserInfoKey檢查它怎么辦呢?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM