【发布时间】:2015-03-19 06:14:53
【问题描述】:
我创建了密码验证。密码创建成功将显示一个UIAlertView,当用户按下确定时,密码文本字段将被清除。怎么做?请问有什么例子吗?
【问题讨论】:
标签: ios objective-c
我创建了密码验证。密码创建成功将显示一个UIAlertView,当用户按下确定时,密码文本字段将被清除。怎么做?请问有什么例子吗?
【问题讨论】:
标签: ios objective-c
添加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;
}
}
【讨论】:
你的问题不清楚。如果您希望在显示 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];
【讨论】: