gpt4 book ai didi

ios - 如何在 ios 8 的 alertview 中添加文本输入?

转载 作者:IT老高 更新时间:2023-10-28 11:36:44 25 4
gpt4 key购买 nike

我想在 ios 8 的警报 View 中添加文本输入。我知道它是使用 UIAlertController 完成的,但不知道。怎么做 ?

最佳答案

截图

代码

 UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"Login"
message: @"Input username and password"
preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"name";
textField.textColor = [UIColor blueColor];
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.borderStyle = UITextBorderStyleRoundedRect;
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"password";
textField.textColor = [UIColor blueColor];
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.secureTextEntry = YES;
}];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSArray * textfields = alertController.textFields;
UITextField * namefield = textfields[0];
UITextField * passwordfiled = textfields[1];
NSLog(@"%@:%@",namefield.text,passwordfiled.text);

}]];
[self presentViewController:alertController animated:YES completion:nil];

关于ios - 如何在 ios 8 的 alertview 中添加文本输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33996443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com