0

を選択しcellて何かを書き込んだ後、キーボードの戻る/次へのボタンを押して、単に次の に移動しcellたいと思います。それが私が達成しようとしていることです。しかしbreakpoint、メソッドに a を配置した後textfieldShouldReturn、return/next キーを押してもアクセスされないことがわかりました。誰かが理由を説明できますか?

ありがとうございました。

4

2 に答える 2

0

とはどういう意味ですかcellUITextFieldがにあり、cellに設定さdelegateれている場合にのみ呼び出されますself

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

[cell.contentView addSubview:txt];

その後、間違いなくtextFieldShouldReturnメソッドが呼び出されます。リターンクリックで

于 2011-09-23T04:04:30.517 に答える
0
@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;
}
于 2011-09-24T02:55:06.613 に答える