I loadView create a UITextField ivar.
1 2 3 4 5 6 7 8 9 10 11 |
- (void)loadView { [super loadView]; _userNameTextField = [[UITextField alloc] initWithFrame:CGRectMake(30, 10, 280, 30)]; _userNameTextField.placeholder = @"Введите имя пользователя"; [_userNameTextField setClearButtonMode:UITextFieldViewModeWhileEditing]; _userNameTextField.returnKeyType = UIReturnKeyGo; _userNameTextField.delegate = self; _userNameTextField.tag = 1; ... |
In ViewDidAppear make it first responder:
1 2 3 4 5 6 |
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [_userNameTextField becomeFirstResponder]; } |
In cellForRow add it as a subview:
1 2 3 4 5 6 |
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] init]; if (indexPath.section == 0) { if (indexPath.row == 0) { [cell addSubview:_userNameTextField]; |