2015-03-19 69 views

回答

0

添加UIAlertViewDelegate協議

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TITLE_HERE" 
               message:@"ALERT_MESSAGE HERE." 
               delegate:self 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
[alert show]; 

用戶按下確定後,這種方法會自動調用:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { 
    // the user clicked OK 
    if (buttonIndex == 0) { 
     // do something here... 
     yourTextField.text = nil; 
    } 
} 
0

你的問題不明確。如果您希望在顯示UIAlert後密碼字段文本爲空,請添加以下代碼以使您的密碼爲空。

yourTextField.text = "" 

下面是一個例子。

if(passwordValid==YES) 
{ 
UIAlertView *passwordValidated = [[UIAlertView alloc] initWithTitle:@"Password Validated!" 
                          message:@"Your password is successfully validated. Press OK to continue" 
                         delegate:nil 
                       cancelButtonTitle:@"OK" 
                       otherButtonTitles:nil]; 

yourTextField.text = ""; 


[updateMessage show];       
相關問題