美文网首页
UITextField shouldChangeCharacte

UITextField shouldChangeCharacte

作者: McIntosh | 来源:发表于2018-03-14 16:08 被阅读0次

之前想找个方法在UITextField输入时,实时获取输入文本,找到shouldChangeCharactersInRange回调方法,但是找个方法拿到里面的textField.text发现比输入的字符少一个很是郁闷。最后找到了一个方法,就是在这个回调方法里面,调用:

      NSString * str = [textField.text stringByReplacingCharactersInRange:range withString:string];

这个方法,就能拿到里面的真实输入内容了。这个可以用这个回调,实时取到输入的内容加已处理。

希望能对大家有所帮助~~

相关文章

网友评论

      本文标题:UITextField shouldChangeCharacte

      本文链接:https://www.haomeiwen.com/subject/lcwfqftx.html