gpt4 book ai didi

xcode - 连续检查两个 NSSecureTextField

转载 作者:行者123 更新时间:2023-12-03 17:25:22 24 4
gpt4 key购买 nike

我怎样才能做到一直检查 2 个 NSSecureTextFields 以了解它们是否相同/不同,从而无需按钮即可显示图像?

.h 文件:

IBOutlet NSSecureTextField *textField;
IBOutlet NSSecureTextField *textField2;
IBOutlet NSImageView *imagem;
}

- (IBAction)verificarPass:(id)sender;

.m 文件:

- (IBAction)verificarPass:(id)sender;
{
NSString *senha1 = [textField stringValue];
NSString *senha2 = [textField2 stringValue];
NSImage *certo;
NSImage *errado;
certo = [NSImage imageNamed:@"Status_Accepted.png"];
errado = [NSImage imageNamed:@"Error.png"];

if ([senha1 isEqualToString:senha2]) {
[imagem setImage:certo];
}else{
[imagem setImage:errado];
}
}

最佳答案

向 textField 控件添加目标方法,由 UIControlEventEditingChanged 控件事件触发:

[textField addTarget:self action:@selector(verificarPass:) forControlEvents:UIControlEventEditingChanged];

关于xcode - 连续检查两个 NSSecureTextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6797904/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com