Detect if user clicked Go or hide UITextField keyboard

I am making a browser type application.

Now I made Url included in the text box ... which displays the keyboard ..

Now I made it a Url type keyboard. she has a Go button, and for iPad, a button to hide the keyboard.

-(BOOL)textFieldShouldReturn:(UITextField *)textField

I know above, this is a method that is called when the user clicks on the keyboard. but for the iPad ... there are two different things .. I want to go to the new URL if the user clicks Go .. and leave the window as it is if the user clicks hide the keyboard .. but the problem is that the report about events

-(BOOL)textFieldShouldReturn:(UITextField *)textField

, since I can distinguish the user from the pressed Go .. or just hide the keyboard.

+3
source share
4

-, , Go

-(BOOL)textFieldShouldReturn:(UITextField *)textField

.

, ... .. , . , - .

+4

"", UIKeyboardWillHideNotification, .

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


- (void) keyboardWillHideHandler:(NSNotification *)notification {
    //show another viewcontroller here
}
+12

, , .

0

At least in iOS 12, textFieldDidEndEditing (_ :) is called when the hide button is pressed (on iPad).

Hope this helps.

0
source

All Articles