在UITextField中禁用放大镜 [英] Disable Magnifying Glass in UITextField
问题描述
有没有办法防止用户在UITextField中移动光标?
没有办法阻止他们移动光标。但是,您可以阻止他们编辑文本,除非最后执行
- textField:shouldChangeCharactersInRange:replacementString:
编辑:您也可以设置 userInteractionEnabled
至 NO
,以便用户无法点击该字段。手动调用 becomeFirstResponder
,以便该字段获得焦点,因为用户无法点按焦点。
Is there a way to prevent the user from moving the cursor in a UITextField? I'd like it to stay at the end of the string.
There's no way to prevent them from moving the cursor. You can, however, prevent them from editing the text except at the end by implementing the
– textField:shouldChangeCharactersInRange:replacementString:
method in your text field's delegate.
Edit: you can also set userInteractionEnabled
to NO
so that the user can't tap the field. Call becomeFirstResponder
manually so that the field gets focus since the user can't tap to focus.
这篇关于在UITextField中禁用放大镜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!