shouldChangeCharactersInRange 方法在目标 c 中不起作用 [英] shouldChangeCharactersInRange method not work in objective c

查看:39
本文介绍了shouldChangeCharactersInRange 方法在目标 c 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的方法在下面,它出错了,当我将 22222222222 写入 TCKimlik 文本字段时,它必须写入 AdText.text = @"AYŞE";但是这种方法将 AYŞE 写入 TCKimlikText.AdText 文本字段显示为空.怎么解决?

My method is below, it wrong works, when I write the 22222222222 to TCKimlik text field, it must be write the AdText.text = @"AYŞE"; But this method write AYŞE to TCKimlikText.And the AdText textfield shows empty. How can I solve?

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

if ([[TCKimlikText.text stringByReplacingCharactersInRange:range withString:string] isEqual:@"22222222222"])
{   

    cinsiyetBtn.titleLabel.text = @"BAYAN";
    AdText.text = @"AYŞE";
    uyrukBtn.titleLabel.text = @"TC";
    babaAdiText.text = @"KEMAL";
    anneAdiText.text = @"ZELİHA";
    soyadiText.text = @"AYDIN";
    anneKizlikSoyadiText.text = @"DEMİRCİ";
    dogumTarihiText.text = @"01/01/1963";
    medeniDurumBtn.titleLabel.text = @"EVLİ";
    //EsinizinAdiText.text = @"AYŞE";
    dogumYeriBtn.titleLabel.text = @"BURSA";
    kimlikBtn.titleLabel.text = @"Nüfus Cüzdanı";
    //KimlikVerilisNedeniText.text = @"YENİLEME";
    //KimlikVerilisTarihi.text = @"12/01/2010";
    kimlikSeriNoText.text = @"57689";
    vergiKimlikNoText.text = @"45678";
    kimlikSiraNoText.text = @"5443126274";
    yakinlikBtn.titleLabel.text = @"EŞİ";
    kizlikSoyadiText.text = @"YILMAZ";
}

return YES;

}

推荐答案

您是否测试过 if 子句中的代码是否被调用?如果是这样,请检查 XIB 文件的属性,可能是 xib 和代码之间的连接已断开(未链接).否则,请尝试:

Have you tested whether your code within the if-clause gets called at all? If so, check the properties of the XIB-file, maybe the connections between the xib and the code is broken (not linked). Otherwise, try:

if ([[TCKimlikText.text stringByReplacingCharactersInRange:range withString:string] isEqual:@"22222222222"])
{
    NSLog("Success");
    // Rest of your code...
}

看看你的说法是否正确.希望这会有所帮助!

to see if your statement is correct. Hope this helps!

这篇关于shouldChangeCharactersInRange 方法在目标 c 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆