• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Stupid (virtual) keyboard mistake... I think
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid (virtual) keyboard mistake... I think


  • Subject: Re: Stupid (virtual) keyboard mistake... I think
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 20 Jul 2011 12:23:10 -0700

On Tue, 19 Jul 2011 18:57:37 -0500, William Squires <email@hidden> 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 = email@hidden, <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 (email@hidden)

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:

This email sent to email@hidden

  • Prev by Date: Re: Dismissing a Popover Internally
  • Next by Date: Re: Dismissing a Popover Internally
  • Previous by thread: Re: Stupid (virtual) keyboard mistake... I think
  • Next by thread: linking an Apple framework into a static lib project and then linking the static lib into an application project...
  • Index(es):
    • Date
    • Thread