This is where UITableView cells are created, usually
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
(one of the delegates for a UITableView ).
So, if you subclass UITableViewCell and set the text property, you can do what you want, including holding an instance of UITextField in the cell. Make sure you use dequeue material as usual.
Then, when the user touches UITableViewCell , you can highlight the UITextField focus:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.thatTextFieldIMentioned becomeFirstResponder]; }
If you subclass UITableViewCell a UITextFieldDelegate and make it a delegate for a text field, you can easily handle these annoyingly hard-to-catch methods:
- (void)textFieldDidEndEditing:(UITextField *)textField { NSLog(@"yeah inform someone of my change %@", textField.text); } - (BOOL)textFieldShouldClear:(UITextField *)textField { return YES; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; }
Dan rosenstark
source share