gpt4 book ai didi

ios - 新 iOS 7 模拟器中的登录弹出错误无法验证用户凭据

转载 作者:行者123 更新时间:2023-11-29 13:02:23 25 4
gpt4 key购买 nike

我一直在尝试让这个在 iOS 6.0 中创建的登录模块在 iOS 7.0 中工作,但我遇到了很多错误。我尝试使用 alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;。但我真的想不出任何方法来解决这个问题。请有人帮我使这段代码工作。这是我当前的代码。

我收到以下错误“libobjc.A.dylib-[NSObject performSelector:withObject:withObject:]:”

“libdispatch.dylib
_dispatch_mgr_thread:”

    NSString *message = [[NSString alloc] initWithFormat:@"Login\n\n\n"];

UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Enter user ID and password"
message: message
delegate: self
cancelButtonTitle: @"Cancel"
otherButtonTitles: @"OK", nil];

alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;

idField = [alert textFieldAtIndex:0];
passwordField = [alert textFieldAtIndex:1];

NSLog(@"idField: %@\npasswordField: %@", idField.text, passwordField.text);

[alert addSubview:idField];
[idField becomeFirstResponder];
[alert addSubview:passwordField];
[passwordField becomeFirstResponder];

//UITextField *idField = [alert textFieldAtIndex:0];
// UITextField *passwordField = [alert textFieldAtIndex:1];

// UITextField *_textField = [message textFieldAtIndex:0];

/* commented by Uday Kanike
UITextField *text = [alert textFieldAtIndex:0];
idField = text;
[alert setDelegate:self];
[alert setTitle:@"Entry User Name..."];
[alert setMessage:@""];
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"OK"];

[idField setPlaceholder:@"Entry User Name..."];
idField.autocapitalizationType = UITextAutocapitalizationTypeWords;
idField.autocorrectionType = UITextAutocorrectionTypeNo;
[alert addSubview:idField];
[alert show];
[idField becomeFirstResponder];


UITextField *text1 = [alert textFieldAtIndex:1];
passwordField = text1;
[alert setDelegate:self];
[alert setTitle:@"Entry Password..."];
[alert setMessage:@""];
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"OK"];

[passwordField setPlaceholder:@"Entry Password..."];
[alert addSubview:passwordField];
// idField.autocapitalizationType = UITextAutocapitalizationTypeWords;
// idField.autocorrectionType = UITextAutocorrectionTypeNo;

[alert show];
[passwordField becomeFirstResponder];

[alert release];
[idField release];
[passwordField release];
*/
// NSString *title = [alert buttonTitleAtIndex:12];
// if([title isEqualToString:@"Login"])
// {
// UITextField *username = [alert textFieldAtIndex:0];
// UITextField *password = [alert textFieldAtIndex:1];
// NSLog(@"Username: %@\nPassword: %@", username.text, password.text);
// }

/*UILabel *passwordLabel = [[UILabel alloc] initWithFrame:CGRectMake(12,40,260,25)];
passwordLabel.font = [UIFont systemFontOfSize:16];
passwordLabel.textColor = [UIColor whiteColor];
passwordLabel.backgroundColor = [UIColor clearColor];
passwordLabel.shadowColor = [UIColor blackColor];
passwordLabel.shadowOffset = CGSizeMake(0,-1);
passwordLabel.textAlignment = UITextAlignmentCenter;
[alert addSubview:passwordLabel];
[passwordLabel release];

UIImageView *passwordImage = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"passwordfield" ofType:@"png"]]];
passwordImage.frame = CGRectMake(11,79,262,31);
[alert addSubview:passwordImage];
[passwordImage release];

UIImageView *passwordImage2 = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"passwordfield" ofType:@"png"]]];
passwordImage2.frame = CGRectMake(11,44,262,31);
[alert addSubview:passwordImage2];
[passwordImage2 release];*/


/*
idField = [[UITextField alloc] initWithFrame:CGRectMake(16,48,252,25)];
idField.font = [UIFont systemFontOfSize:18];
idField.backgroundColor = [UIColor whiteColor];
idField.secureTextEntry = NO;
idField.placeholder = @"User ID";
idField.keyboardAppearance = UIKeyboardAppearanceDefault;
[alert addSubview:idField];
[idField becomeFirstResponder];

passwordField = [[UITextField alloc] initWithFrame:CGRectMake(16,83,252,25)];
passwordField.font = [UIFont systemFontOfSize:18];
passwordField.backgroundColor = [UIColor whiteColor];
passwordField.secureTextEntry = YES;
passwordField.placeholder = @"Password";
passwordField.keyboardAppearance = UIKeyboardAppearanceAlert;
// passwordField.delegate = self;

alert.delegate = self;
alert.tag = 200;
[alert addSubview:passwordField];

[passwordField becomeFirstResponder];
*/
idField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"SUPUserID"];
passwordField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"SUPUserPassword"];

RequestHandler *request = [RequestHandler uniqueInstance];
[request unregisterUser];

//[alert setTransform:CGAffineTransformMakeTranslation(0,0)];

[alert show];
[alert release];
[message release];

最佳答案

尝试使用下面的代码,它工作正常。

 -(void)showLoginView
{
NSString *message = [[NSString alloc] initWithFormat:@"Login"];

UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Enter user ID and password" message: message delegate: self cancelButtonTitle: @"Cancel" otherButtonTitles: @"OK", nil];
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
[alert setTag:111];
[alert show];

idField = [alert textFieldAtIndex:0];
passwordField = [alert textFieldAtIndex:1];

idField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"SUPUserID"];
passwordField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"SUPUserPassword"];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag == 111)
{
NSLog(@"idField: %@\npasswordField: %@", idField.text, passwordField.text);

}
}

关于ios - 新 iOS 7 模拟器中的登录弹出错误无法验证用户凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19458088/

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