gpt4 book ai didi

objective-c - objective-c 中的UITextField shouldChangeCharactersInRange方法

转载 作者:行者123 更新时间:2023-12-01 18:30:50 26 4
gpt4 key购买 nike

我有一些textField,当我将11111111111写入第一个文本字段(TCKimlikText)时,我将一些字符串设置为其他文本字段。同样,第一个文本字段的最大长度(TCKimlikText)必须为11个字符。我尝试下面的代码。但是我有一个问题。我无法删除我写到TCKimlikText文本字段的内容。

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{


if (TCKimlikText.text.length <11) {

if ([[TCKimlikText.text stringByReplacingCharactersInRange:range withString:string] isEqual:@"11111111111"])
{
AdinizText.text = @"MEHMET";
uyrukBtn.titleLabel.text = @"TC";
BabaAdiText.text = @"HASAN";
AnneAdiText.text = @"MELEK";
SoyadinizText.text = @"AYDIN";
AnneKizlikSoyadiText.text = @"OKUR";
DogumTarihiText.text = @"01/01/1960";
medeniDurumBtn.titleLabel.text = @"EVLİ";
EsinizinAdiText.text = @"AYŞE";
dogumYeriBtn.titleLabel.text = @"BURSA";
kimlikTuruBtn.titleLabel.text = @"Nüfus Cüzdanı";
KimlikVerilisNedeniText.text = @"YENİLEME";
KimlikVerilisTarihi.text = @"12/01/2010";
KimlikSeriNoText.text = @"16345";
VergiKimlikNoText.text = @"45678";
EvTelText.text = @"5443126274";
}
return YES;


}

else return NO;


}

我该如何解决?

最佳答案

最好的方法如下:

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{

NSString *resultStr = [TCKimlikText.text stringByReplacingCharactersInRange:range withString:string];

if (resultStr.length < 12)
{

if ([resultStr isEqual:@"11111111111"])
{
NSLog(@"In");
AdinizText.text = @"MEHMET";
uyrukBtn.titleLabel.text = @"TC";
BabaAdiText.text = @"HASAN";
AnneAdiText.text = @"MELEK";
SoyadinizText.text = @"AYDIN";
AnneKizlikSoyadiText.text = @"OKUR";
DogumTarihiText.text = @"01/01/1960";
medeniDurumBtn.titleLabel.text = @"EVLİ";
EsinizinAdiText.text = @"AYŞE";
dogumYeriBtn.titleLabel.text = @"BURSA";
kimlikTuruBtn.titleLabel.text = @"Nüfus Cüzdanı";
KimlikVerilisNedeniText.text = @"YENİLEME";
KimlikVerilisTarihi.text = @"12/01/2010";
KimlikSeriNoText.text = @"16345";
VergiKimlikNoText.text = @"45678";
EvTelText.text = @"5443126274";
}
return YES;

}

else return NO;

}

当有人将文本粘贴到您的文本字段中时,这也将为您提供帮助。

关于objective-c - objective-c 中的UITextField shouldChangeCharactersInRange方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9030382/

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