Hi
I am making a search form with a number of free text fields that I would like the user to edit in line on a tableview (and not go to a seperate view for each individual item). So far I have it so when you press on the field, a text input dialog appears, here is the relevant code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 130, 25)];
label.textAlignment = UITextAlignmentRight;
label.tag = kLabelTag;
[cell.contentView addSubview:label];
[label release];
UITextField *theTextField = [[UITextField alloc] initWithFrame:CGRectMake(150, 10, 140, 25)];
theTextField.tag = kTextFieldTag;
theTextField.delegate = self;
[cell.contentView addSubview:theTextField];
[theTextField release];
This has the desired effect of allowing a user to press a row and get an edit dialog, but I have a few problems:
1) You can see I have set the text field's delegate to equal self. The class this is run in implements UITextFieldDelegate yet textFieldShouldEndEditing
is not being fired.
2)How can i realisticly persist what the user puts in memory. In other words, is it possible to find out which text field the user has selected currently so i can go [myArray getObjectAtIndex:blah]
and edit the actual data.
Thanks