选择 acell
并在其中写入内容后,我想点击键盘上的 return/next 按钮并简单地移动到 next cell
,这就是我想要实现的。但是breakpoint
在我的方法上放置 a 之后textfieldShouldReturn
,我发现它没有被访问,即使我按下了 return/next 键。有人可以解释为什么吗?
谢谢你。
选择 acell
并在其中写入内容后,我想点击键盘上的 return/next 按钮并简单地移动到 next cell
,这就是我想要实现的。但是breakpoint
在我的方法上放置 a 之后textfieldShouldReturn
,我发现它没有被访问,即使我按下了 return/next 键。有人可以解释为什么吗?
谢谢你。
你是什么意思cell
。它只会在你有UITextField
并且cell
也设置为时delegate
调用self
。
UITextField *txt=[[UITextField alloc]initWithFrame:CellFrame];
text.tag=indexPath.row;
txt.delegate=self;
[cell.contentView addSubview:txt];
那么它肯定会调用textFieldShouldReturn
方法。返回点击
@interface WordListTableController : UITableViewController <UITextFieldDelegate>
{
}
@end
// 自定义表格视图单元格的外观。- (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;
}