I am on iOS 6 xcode 4.6.2 using storyboards.
I am using a dynamic UITableView
which consists of a number of cells each of which have two UITextFields
on them. The two fields are defined in a custom cell as
@property (strong, nonatomic) IBOutlet UITextField *lowRangeField;
@property (strong, nonatomic) IBOutlet UITextField *highRangeField;
I wish to use
-(void) textFieldDidEndEditing:(UITextField*) textfield
to get at the values and save it into a core data store.
Now, obviously, I can get at the value and assign it where I like, because I have the pointer to the textfield
. My issue is I don't know how to identify which field on the cell
this actually is. I know I can get the textfields
superview
to identify which cell its on , so I can work out which set of lowRangeField and highRangeField it is but then I get stuck.
My issue is I don't know how to identify which field on the cell this actually is.
Use Tag to Identify.
lowRangeField.tag = 1;
highRangeField.tag = 2;
-(void) textFieldDidEndEditing:(UITextField*) textfield
{
if (textField.tag == 1) {
NSLog(@" clicked in lowRangeField");
} else if (textField.tag ==2) {
NSLog(@" clicked in highRangeField");
}
}
Try this one
This is used to identify in which text field you have entered value .
- (void)viewDidLoad
{
lowRangeField.tag = 100;
highRangeField.tag = 200;
}
-(void) textFieldDidEndEditing:(UITextField*) textfield
{
if (textField.tag == 100)
{
NSLog(@" clicked On lowRangeField");
}
else if (textField.tag ==200)
{
NSLog(@" clicked On highRangeField");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With