Brandon
Brandon

Reputation: 2171

Automatically Select First UITableView Textbox

I have a tableview that accepts login credentials. I would like to have my app automatically select the first tableview text box upon loading or appearing. I would like the cursor to be placed in the "Email Address" field and for the keyboard to be raised automatically. I can't seem to figure this out. Anyone have any ideas? Thank you!

enter image description here

Upvotes: 4

Views: 904

Answers (2)

Baby Groot
Baby Groot

Reputation: 4279

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

myTextField = (UITextField *)[cell viewWithTag:kMyTextFieldTag];
[myTextField becomeFirstResponder];
}

Upvotes: 2

apascual
apascual

Reputation: 2980

You have to assign the first responder to that UITextView...

For example:

[textField becomeFirstResponder]

You can do it in the viewDidAppear of the UIViewController.

Upvotes: 6

Related Questions