2017-09-28 7 views
0
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillShow, object: nil) 

func keyboardWillHide(notification: NSNotification) { 
    if let rect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue { 

    } 
} 

ところで、関数は正しいRectValueを与えません。 これは何が問題ですか?iOS11でのキーボードの問題

+0

あなたが取得している矩形で何が悪いですか? – Vakas

+0

これにはQuickTypeBarの高さは含まれていません。 – Wang90925

+0

どのタイプバーですか?あなたはオートコレクトバーについて話していますか? – Vakas

答えて

0

はこれを試してみてください:

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil) 

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil) 

func keyboardWillHide(notification: NSNotification) { 
     if let rect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue { 

     } 
    } 
func keyboardWillShow(notification: NSNotification) { 
     if let rect = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { 

     } 
    } 
+0

'UIKeyboardFrameEndUserInfoKey'は 'keyboardWillHide'に、' UIKeyboardFrameBeginUserInfoKey'は 'keyboardWillShow'になければなりません – Vakas

関連する問題