UIAlertController文本框

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *okButton = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *Action) {
        UITextField *textField = alert.textFields.firstObject;//设置第一响应者
        NSLog(@"%@",textField.text);
}];

[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.placeholder = @"string";
}];
[alert addAction:okButton];
[self presentViewController:alert animated:YES completion:nil];

你可能感兴趣的:(UIAlertController文本框)