views:

28

answers:

2

How do I know when a user taps on the Join button on the UIKeyboard?

Also can this text be changed? I know there are several built options but I nee done that says 'Login' if I can.

A: 

You should set your delegate of your UITextField (I'm assuming that's a UITextField) and check for that delegate call :

- (BOOL)textFieldShouldReturn:(UITextField *)textField

Also, you return a BOOL to tell the UITextField to do its default behavior or not. You can check the documentation here.

Also, the options Apple gives you for the UIReturnKeyType are your only options.

gcamp
+1  A: 

I'm not a big fan of using UITextField delegate just for knowing when keyboard entry is completed by pressing the "return" on the keyboard (whatever it's labeled). UITextField actually works well with a Target/Action pattern which is much simpler and far more direct than using the delegate for this.

I've pointed this out before in an answer to "How to call a method when the Done Button in the KeyBoard is Clicked?". Please take a look at that for the details of using the traditional target/action pattern to know when keyboard entry is complete. Unfortunately, Apple's documentation isn't as clear is it could be on this subject.

UITextField delegate has its place, but if all you need is to know when entry is complete then using the delegate likely isn't the best approach. Use target/action.

For the UIReturnKeyType choices, see the returnKeyType property in the UITextInputTraits Protocol Reference.

Jay O'Conor