Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2009, 07:29 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Age: 34
Posts: 27
nghtstr is on a distinguished road
Send a message via AIM to nghtstr
Question UITextField "onChange" functionality...

Hey all,

This may be another simple solution, I am just unsure what to start looking for.

I have a form, with some UITextFields in it. I would like to perform some action, based off from the name of the field, and perform some action upon leaving the field.

Here is the catcher (I think), that while each would be named differently, the basic premise of what it would do is identical in each instance. I could use with some help on this one.

Oh, and to just throw ONE more wrinkle in it, while right now I am dealing with UITextFields, I would also like to do the same functionality with Checkboxes and Drop Downs.

Thanks for the advice and help!!
nghtstr is offline   Reply With Quote
Old 02-06-2009, 07:40 PM   #2 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2009
Location: Los Angeles
Posts: 7
jhzafrani is on a distinguished road
Send a message via Yahoo to jhzafrani
Default

Tag all of your controls with identifying information that could give you both the type and the name (like "opt_option1" for an option button or "txt_firstname" for a textfield). You could connect all the controls to the same IBAction as long as you define its parameter as id type. Once in the function, you could check the tag of the object and execute the appropriate code.

That should work without a problem.
jhzafrani is offline   Reply With Quote
Old 02-06-2009, 09:29 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Age: 34
Posts: 27
nghtstr is on a distinguished road
Send a message via AIM to nghtstr
Default

Quote:
Originally Posted by jhzafrani View Post
Tag all of your controls with identifying information that could give you both the type and the name (like "opt_option1" for an option button or "txt_firstname" for a textfield). You could connect all the controls to the same IBAction as long as you define its parameter as id type. Once in the function, you could check the tag of the object and execute the appropriate code.

That should work without a problem.
The only part of that is that upon leaving the element, or changing the element is when I want that code to be executed. How would I go about that?

Other than that, that is a really great idea, thanks!!
nghtstr is offline   Reply With Quote
Old 02-07-2009, 12:11 AM   #4 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2009
Location: Los Angeles
Posts: 7
jhzafrani is on a distinguished road
Send a message via Yahoo to jhzafrani
Default

Quote:
Originally Posted by nghtstr View Post
The only part of that is that upon leaving the element, or changing the element is when I want that code to be executed. How would I go about that?

Other than that, that is a really great idea, thanks!!
Well, connect the IBAction to each of the component's "changed" event. Since you are declaring it as an id, it won't make a difference as to the control. Then, all you have to do in the function code is determine the type of control based on the tag, create a new control class and cast the sender property (id type) to the correct control class to get the properties that you want.

Jim
jhzafrani is offline   Reply With Quote
Reply

Bookmarks

Tags
onchange, text field, uitextfield

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
6 members and 317 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog, Objective Zero
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0