セルのテキスト フィールドのデリゲートをビュー コントローラーに設定しても問題はありません。
これはあなたがする必要があることです:
1)View ControllerはUITextFieldDelegate
プロトコル を実装する必要があります
2) カスタム セルのテキスト フィールドのプロパティを宣言します。
@property (nonatomic, retain) IBOutlet UITextField *textField;
3) 次に、View Controller をメソッドでテキスト フィールドのデリゲートとして設定します。 cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
// use this if you created your cell with IB
cell = [[[NSBundle mainBundle] loadNibNamed:@"MyCustomCell" owner:self options:nil] objectAtIndex:0];
// otherwise use this
cell = [[[MyCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
// now set the view controller as the text field delegate
cell.textField.delegate = self;
}
// configure cell...
return cell;
}