keyboardWillShow will only work from the second ti

2019-04-13 18:00发布

问题:

I have a UITextView that I need to move up when the user focuses on it.

In the simulator I have set up 2 keyboards (English,Greek)

Within keyboardWillShow function I change the UITextView's height to be less than the existing one, as in

self.page_text.frame = CGRectMake(self.page_text.frame.origin.x, self.page_text.frame.origin.y, self.page_text.frame.width, (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue().origin.y - 180)

The problem is that only each first time I focus on the text view the keyboard appears but the UITextView's height does not change:

After that first time, each time I change the keyboard's language the text view behaves as expected.

Why could this be happening?

The project can be found here

PS: I noticed that if the two keyboards are in the same language (ex US English and UK English), the height never changes. How strange is that?