以编程方式选择UITextField中的所有文本 [英] Programmatically Select all text in UITextField
本文介绍了以编程方式选择UITextField中的所有文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以编程方式选择UITextField中的所有文本?
How can I programmatically select all text in UITextField?
推荐答案
原来,调用-selectAll:非零发件人显示菜单。用nil调用它会导致它选择文本,但不会显示菜单。
Turns out, calling -selectAll: with a non-nil sender displays the menu. Calling it with nil causes it to select the text, but not display the menu.
我在我的错误报告之后尝试了这个,因为它是从Apple回来的,建议我传递nil而不是self。
I tried this after my bug report about it came back from Apple with the suggestion that I pass nil instead of self.
无需使用UIMenuController或其他选择API。
No need to muck with UIMenuController or other selection APIs.
这篇关于以编程方式选择UITextField中的所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文