gpt4 book ai didi

objective-c - ios8 UIAlertView 成为密码 UITextField 的第一响应者不起作用

转载 作者:太空狗 更新时间:2023-10-30 03:45:49 26 4
gpt4 key购买 nike

这在 iOS7 中工作正常。升级到 iOS8 后,奇怪的是无法正常工作。

因此,如果用户之前已经登录过,则保存用户名并需要输入密码。很简单,我只是在 0 索引 UITextField 中输入用户名,并将光标设置在 UIAlertView 的 1 索引 UITextField

之前,我只需将 becomeFirstResponder 设置为 UIAlertView 中的编号 1 索引 UITextField。奇怪的是,我实际上可以将文本设置到编号为 1 的索引 UITextField 中。所以我知道我仍在正确访问 UITextField

非常简单的代码。

这是我的代码...

- (IBAction)actionTesting:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:@"" delegate:self cancelButtonTitle:@"Login" otherButtonTitles: nil];
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
alert.tag = 999;

UITextField *txtUserName = [alert textFieldAtIndex:0];
UITextField *txtPassword = [alert textFieldAtIndex:1];

txtUserName.text = @"";
txtPassword.text = @"";

[alert textFieldAtIndex:1].delegate = self;
[alert show];
}

-(void)didPresentAlertView:(UIAlertView *)alertView{
UITextField *txtUserName = [alertView textFieldAtIndex:0];
UITextField *txtPassword = [alertView textFieldAtIndex:1];
txtUserName.text = @"username";
txtPassword.text = @"password";
[txtPassword becomeFirstResponder];
}

看起来我们有一个新的 UIAlertController 可用。我只是希望它能正常工作,所以我现在不必对我的原始代码做任何更改。

最佳答案

看起来 Apple 已更正此问题。我前几天才注意到该功能正在运行

关于objective-c - ios8 UIAlertView 成为密码 UITextField 的第一响应者不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25998048/

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