Home  >  Q&A  >  body text

objective-c - textfield输入字符串过滤

textField输入的时候过滤字符串,只能输入中文,其他的都不让输入

伊谢尔伦伊谢尔伦2698 days ago644

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-05-02 09:29:53

    During the input process, I first use regular expressions to determine whether the input is Chinese. If it is Chinese, assign it to textfiled.text, and then store this value in a global variable. Later, when textfiled.text changes, if there is a non-Chinese character Characters, use the previously stored global variables to intercept the string, and only the Chinese string is assigned to textfiled.text, so that textfiled can only input Chinese during the input process.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-02 09:29:53

    You can judge the text in the proxy method. If there are English numbers, just delete them

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:29:53

    This may not be possible, because when typing Chinese pinyin before finishing typing, the English words will be displayed. If there are non-Chinese characters in the construction, the save button will be grayed out, and the user will be prompted to delete the non-Chinese characters.

    reply
    0
  • Cancelreply