On Tue, 19 Jul 2011 18:57:37 -0500, William Squires <wsqui...@satx.rr.com> said:
>  What's the proper way to detect if the "Enter" key on the virtual 
> (on-screen) keyboard in iOS is touched?
>  Is this part of the UITextField delegate protocol? Or is it supposed to be 
> the "Editing Did End" event you see when you right-click on the UITextField 
> in question (in IB, of course)?

Here's what my book would have suggested to you:

* Approach 1 - Implement the delegate method, textFieldShouldReturn:, and tell 
the text field to resign first responder status. Nothing wrong with this.

* Approach 2 - Send the text field this message:

   [textField addTarget:nil action:@selector(dummy:) 
forControlEvents:UIControlEventEditingDidEndOnExit];

The result of Approach 2 will be that, as if by magic, it will automatically 
dismiss the keyboard when the user taps Enter, with no intervention on your 
part. The reason is that this dismissal takes place if the text field has its 
"end editing on exit" hooked up, even if it is unhandled. So Approach 2 has the 
advantage of being Extremely Cool. :) You can set up the same thing in the nib 
instead of code if you like. m.

--
matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to