My app has a UITextField inside of a table cell. The table cell is build inside of a TableController class which is the table delegate as well. The TableController is a instance variable of a ViewController class.
What I'm trying to do is to send a message to the ViewController instance when the user touches inside the TextField.
This is a code snipped from the TableController:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"test";
UITextField *textField = [[[UITextField alloc] initWithFrame:CGRectMake(1.0, 5.0, 120.0, 25.0)] autorelease];
textField.text = @"test 2";
[textField addTarget:self action:@selector(editingStarted) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = textField;
return cell;
}
The first problem is that the TableControllers method editingStarted gets never called. The next interesting part will be to send a message to the parent ViewController class.