Re: Setting a delegate on a UITextField
Re: Setting a delegate on a UITextField
- Subject: Re: Setting a delegate on a UITextField
- From: Matt Neuburg <email@hidden>
- Date: Mon, 07 Mar 2011 09:30:05 -0800
On Mon, 07 Mar 2011 09:02:36 -0800 (PST), Jon Sigman <email@hidden> said:
>On Sat, 05 Mar 2011 11:22:46 -0800 Matt Neuburg wrote:
>> One possible approach on iOS is to implement textFieldShouldEndEditing, and
>>return NO and put up an alert if there's a problem. Another is just to make the
>>change yourself in textFieldDidEndEditing. See the section entitled "Validating
>>Entered Text" (along with the preceding section) in the "Managing Text Fields
>>and Text Views" chapter of the Text, Web, and Editing Programming Guide for iOS.
>>
>That looks like a good fit. But is there some trick in
>getting textFieldShouldEndEditing invoked? I have also
>a textFieldDidBeginEditing and a textFieldDidEndEditing method; they get invoked
>when
>the user touches the "Return" key on the keypad, but textFieldShouldEndEditing
>does not.
This has nothing to do with the "Return" key on the keypad - it has to do with the text field resigning its first responder status. The "Return" key invokes textFieldShouldReturn: and does *not* automatically resign first responder (unless you've implemented Did End on Exit). As usual, I suggest you make a teeny little test project, completely clean, consisting of just a text field and its delegate, so as to prove to yourself that textFieldShouldEndEditing: is in fact called. 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