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

如何訪問viewDidLoad或任何其他函數中的「enteredName」值。我已經使用alert.alertViewStyle = UIAlertViewStylePlainTextInput;從alertView訪問值clickedbuttonAtIndex方法

回答

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); 

    } 
} 
+0

thanx jerry ... :) – manish1990