0

After selecting a cell and writing something in it, I would like to hit the return/next button on the keyboard and simply move to the next cell, that's what I am trying to achieve. But after placing a breakpoint on my method textfieldShouldReturn, I find that it does not get visited, even though I pressed on the return/next key. Can someone explain why?

Thank you.

rptwsthi
  • 10,094
  • 10
  • 68
  • 109

2 Answers2

0

What do you mean by cell. It will only call when you have UITextField in the cell and also set delegate to self.

UITextField *txt=[[UITextField alloc]initWithFrame:CellFrame];
text.tag=indexPath.row;
txt.delegate=self;

[cell.contentView addSubview:txt];

then it will definitely call textFieldShouldReturn method. on return click

rptwsthi
  • 10,094
  • 10
  • 68
  • 109
Ishu
  • 12,797
  • 5
  • 35
  • 51
  • I have similar, I tried adding my code as answer but I have to wait 8hours. I have seen several post telling other people with similar issues about files owner and delegate, but how can I make something that is programmatically part of files owner? If that is even the problem? – Neil Porven Sep 23 '11 at 04:23
0
@interface WordListTableController : UITableViewController <UITextFieldDelegate>
{
}

@end

// Customize the appearance of table view cells. - (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];
}

// Configure the cell...
UITextField *FirstField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 130, 25)];
FirstField.delegate = self;
[FirstField setTag:indexPath.row];
FirstField.returnKeyType = UIReturnKeyNext;
[cell.contentView addSubview:FirstField];
[FirstField release];


return cell;
}


// Handle any actions, after the return/next/done button is pressed
- (BOOL)textfieldShouldReturn:(UITextField *)textfield 
{
[textfield resignFirstResponder];

return NO;
}