How to select text automatically inside a UIAlertView text field

I have a UIAlertView with a text box that shows the default value and two buttons, one to cancel and one to confirm. What I'm trying to do is that when a warning appears, the default value appears, which is highlighted so that the user can overwrite the entire value faster than manually erasing it.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Title" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue",nil];
[alert addTextFieldWithValue:@"87893" label:@"value"];
UITextField *textField = [alert textField];
campoTexto.highlighted = YES;
campoTexto.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
[alert show];
[alert release];

}

For some reason, there is a highlighted attribute for the text field, but it does not work, and there is no trace of this attribute in the class documentation.

+3
source share
1 answer

. , , , , .

[alertView show];
[textField selectAll:self];

, campoTexto, , .

+1

Source: https://habr.com/ru/post/1746594/


All Articles