UITextField
デフォルトで各セルの を無効にし、UITableView
デリゲート メソッドdidSelectRowAtIndexPath:
を使用して
- 選択した行の indexPath をプロパティに格納します
- 有効にする
UITextField
UITextField
ファーストレスポンダーを作る
クラス拡張でプロパティを定義します。
@interface MyTableViewController ()
@property (strong, nonatomic) NSIndexPath *activeIndex;
@end
の実装でdidSelectRowAtIndexPath:
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.activeIndex = indexPath;
AddCell *selectedCell = (AddCell *)[self.tableView cellForRowAtIndexPath:indexPath];
[selectedCell.textField setEnabled:YES];
[selectedCell.textField becomeFirstResponder];
}
UITextField
ファーストレスポンダ ステータスを辞任するときは、再度無効にする必要があります。
UITableViewController
yourが each のデリゲートであると仮定すると、メソッドUITextField
の実装でこれを行うことができます。UITextFieldDelegate
-(void)textFieldDidEndEditing:(UITextField *)textField
{
[textField setEnabled:NO];
}