My iphone app has several text fields. The "Did End on Exit" event on each text field calls a single action. How can I tell which text field called the action? Can I detect this from the sender object which is passed to the action?
+3
A:
Sure, just set a tag (NSInteger) on each of the text fields, and then check against them on the sender object.
Look for more details under the documentation for UIView's tag property.
jpm
2009-01-04 23:43:07
+6
A:
The sender
object will be the UITextField in question. If you have a bunch of IBOutlets connecting to your text fields, you can simply compare if sender == aField
to see which field it is.
Kevin Ballard
2009-01-04 23:48:06
note this is assuming you define your action methods like so:- (IBAction) myAction:(id)senderYou can then compare "sender" to whatever IBOutlet UITextField *variable you've defined to attach the text field to in IB.
Kendall Helmstetter Gelner
2009-01-05 01:47:12