我一直试图让这个在 iOS 6.0 中创建的登录模块在 iOS 7.0 中工作,但我遇到了很多错误。我尝试使用alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
. 但我真的想不出任何办法来解决这个问题。请有人帮助我使此代码正常工作。这是我当前的代码。
我收到以下错误“libobjc.A.dylib -[NSObject performSelector:withObject:withObject:]:"
also
"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];