在UIAlertview中添加多个UITextfield

时间:2015-02-24 10:00:10

标签: ios objective-c xcode uitextfield uialertview

我需要在UITextField中添加5 UIAlertView。我用这个项目: https://www.cocoacontrols.com/controls/aralertcontroller

这是我的代码:

ARAlertController *alert = [ARAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:ARAlertControllerStyleAlert];
ARAlertAction* defaultAction = [ARAlertAction actionWithTitle:@"OK" style:ARAlertActionStyleDefault handler:^(ARAlertAction * action) {}];



[alert addAction:defaultAction];
[alert presentInViewController:self animated:YES completion:nil];

有人可以帮我实现UITextField中的(ARAlertController *)alert吗?

由于

1 个答案:

答案 0 :(得分:0)

你必须使用类似的东西:

ARAlertController *alert = [ARAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:ARAlertControllerStyleAlert];
ARAlertAction* defaultAction = [ARAlertAction actionWithTitle:@"OK" style:ARAlertActionStyleDefault handler:^(ARAlertAction * action) {}];
[alert addAction:defaultAction];

[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"First";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"second";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"third";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"fourth";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.placeholder = @"fifth";
}];

[alert presentInViewController:self animated:YES completion:nil];

好的卢克。