I have a simple project that contains a UITableView with a custom cell, in this I cell have a UITextField, So I have a button that calls a function 'addField', When This function is called I increment +1 value for the variable numberOfRows, then I call the command responsible for updating the table, as you can see bellow:
-(void)AddField{
numberOfRows++;
[tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return numberOfRows;
}
Doing so creates a new table row with a new textField to enter another value.
Inside My cell I connect the UITextField with the Outlet,:
IBOutlet UITextField *myFields;
Inside awakeFromNib I have a code who checks whether the user is typing:
- (void)awakeFromNib
{
[campoTexto addTarget:self
action:@selector(change:)
forControlEvents:UIControlEventEditingChanged];
}
-(void)change:(UITextField *)textField{
NSLog(@"What The textField I'm Typing? -> %ld",(long)textField.tag);
}
All I would do is try to find some way to differentiate which text field I'm typing, as well UITableView can differentiate their rows (0 .. n), I think I can differentiate this UITextField (0 ... n).
Can anyone give me some help, or maybe know a tutorial on the web that explain this kind of thing?
Thanks.