IPad: How do I know if the iPad return key is pressed? Please check the image.

I want to know which method is called when the next key is pressed.

keyboard screenshot

I want to start an action on a keystroke.

How do I know it is pressed?

+4
source share
4 answers

Pay attention to the notice UIKeyboardDidHideNotification .

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; 

A...

 - (void)keyboardDidHide:(NSNotification *)aNotification { } 

You can also change it to UIKeyboardWillHideNotification if you need to get a notification before the keyboard starts to fade.

+13
source

This is not a return key. A return key is located above it. This is just a button that rejects the keyboard, and you cannot recognize it using standard text input methods. You need to register to notify UIKeyboardWillHideNotification .

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; 

and implement this method:

 - (void)keyboardWillHide:(NSNotification *)notification { // do whatever you want to do when keyboard dismiss button is tapped } 
+5
source

Not sure if this is exactly what you are looking for, but you can try using notifications. You don’t have a Mac near atm, so just copy the code from github. I have this code in viewDidLoad:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; 

and then 2 methods:

 - (void)keyboardWillShow:(NSNotification *)notification { } - (void)keyboardWillHide:(NSNotification *)notification { } 

Hope this helps

+3
source

Use keyboard hiding UIKeyboardWillHideNotification .

Example.

+3
source

Source: https://habr.com/ru/post/1393144/


All Articles