-5
我創建了密碼驗證。密碼創建成功後,將顯示一個UIAlertView
,並在用戶按下確定時按下,密碼文本字段將變得清晰。怎麼做?請任何例子?使用如何清除iOS中UIAlertView中的UITextfield文本和Ok按鈕?
@interface YourViewController : UIViewController <UIAlertViewDelegate>
顯示警報視圖:
我創建了密碼驗證。密碼創建成功後,將顯示一個UIAlertView
,並在用戶按下確定時按下,密碼文本字段將變得清晰。怎麼做?請任何例子?使用如何清除iOS中UIAlertView中的UITextfield文本和Ok按鈕?
@interface YourViewController : UIViewController <UIAlertViewDelegate>
顯示警報視圖:
添加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;
}
}
你的問題不明確。如果您希望在顯示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];