Return key method in UIInputViewController in iOS8?

I am developing a custom keyboard with keyboard extension in iOS8 .

I can remove the keyboard with the following method.

 [self dismissKeyboard]; 

However, the above method only remove the keyboard. I want to do this as a return method, which may appeal to GO or Search , which may use both rejection and GO Events, such as iOS Built in Keyboard.

How can i do this?

+6
source share
3 answers

You can use [self.textDocumentProxy insertText: @ "\ n"];

+10
source

just call [self rejectKeyboard], self is an instance of UIinputViewController

-1
source

Big question

First of all, the answer to pressing the "GO" or "SEARCH" button is your responsibility. This means that when the user clicks "GO" - in your application you need to catch this event and implement everything that you want there (maybe you are looking for something). This means that you can execute this implementation and just click on it before rejecting the keyboard.

EDIT:

First of all, how to respond to keystrokes in your application:

match the text field delegate:

 @interface MyViewController : UIViewController <UITextFieldDelegate> 

and then override this method with your implementation - what do you want to do when the user clicks on the return key? (or go or search, etc.):

 - (BOOL)textFieldShouldReturn:(UITextField *)textField { // your implementation return YES; } 

This is how you react to clicks on the return key and implement everything you want when you click.

note that you can change the features of the GO and SEARCH buttons with

 theTextField.returnKeyType = UIReturnKeySearch; 

Please note that YOUR implementation is what matters in the whole deal here - and you can simply implement this implementation right before rejecting the keyboard.

Thank you and good luck!

-3
source

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


All Articles