-3
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
        NSString *enteredName = [[alertView textFieldAtIndex:0]text];
        NSLog(@"name===>%@",enteredName);
}

如何在 viewDidLoad 或任何其他函数中访问“enteredName”值。我用过 alert.alertViewStyle = UIAlertViewStylePlainTextInput;

4

1 回答 1

3
   message.alertViewStyle = UIAlertViewStylePlainTextInput;


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"Login"])
 {

    UITextField *username = [alertView textFieldAtIndex:0];
    UITextField *password = [alertView textFieldAtIndex:1];

    NSLog(@"Username: %@\nPassword: %@", username.text, password.text);

  }
}
于 2012-09-17T11:04:29.483 回答