2012-09-17 3 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