【发布时间】:2014-11-05 22:18:41
【问题描述】:
我正在将所有内容从 AlertView 更改为 AlertController,但我无法在网上找到任何用于检索用户在 AlertController 的文本字段中输入的内容的目标 c。这是我所拥有的:
if ([UIAlertController class]) {
UIAlertController *alertControllerK2 = [UIAlertController
alertControllerWithTitle:@"\u00A0"
message:@"Please enter the first number."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *K2okAction = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:nil];
[alertControllerK2 addTextFieldWithConfigurationHandler:^(UITextField *K2TextField)
{
K2TextField.placeholder = NSLocalizedString(@"Please enter the first number.", @"Please enter the first number.");
}];
[alertControllerK2 addAction:K2okAction];
[self presentViewController:alertControllerK2 animated:YES completion:nil];
} else {
UIAlertView *alertK2;
alertK2 = [[UIAlertView alloc]
initWithTitle:@"\u00A0"
message:@"Please enter the first number."
delegate: self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
alertK2.alertViewStyle=UIAlertViewStylePlainTextInput;
[alertK2 show];
}
问题是 K2TextField 是在 UIAlertController 中定义的,所以我无法在该代码之外访问它。但是如果我尝试预定义它,我会收到一条错误消息。任何帮助将不胜感激!
【问题讨论】:
标签: input ios8 uialertcontroller