我创建了密码验证。密码创建成功后会显示一个UIAlertView
并在用户按下确定时按,密码文本字段将变为清除状态。怎么做?请问任何一个例子?
答案 0 :(得分:0)
添加UIAlertViewDelegate
协议:
@interface YourViewController : UIViewController <UIAlertViewDelegate>
使用以下方式显示警报视图:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TITLE_HERE"
message:@"ALERT_MESSAGE HERE."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
用户按OK后,此方法将自动调用:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
// the user clicked OK
if (buttonIndex == 0) {
// do something here...
yourTextField.text = nil;
}
}
答案 1 :(得分: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];