取消键盘后如何保持UITextField的光标焦点? [英] How to keep cursor of a UITextField in focus after dismissing keyboard?
问题描述
我正在尝试关闭OS键盘,并使UITextField的光标保持焦点,我正在尝试这样做,因为我正在构建自定义贴纸键盘.
I am trying to dismiss the OS keyboard and keeping the cursor of the UITextField still in focus, I am trying to do this because I am building a custom stickers keyboard..
所以问题在于,我呼叫resignFirstResponder
后,键盘被关闭,女巫是一种想要的行为,但光标也被解散了,我想保持专注.
So the problem is that after I call the resignFirstResponder
, the keyboard gets dismissed, witch is a wanted behaviour, but also the cursor gets dismissed, witch I want to keep in focus.
推荐答案
没有办法做到.但是,在模拟器中,您可以按 Cmd + K ,这将关闭键盘,但将焦点保留在那里(这是对硬件键盘的模拟).但通常,UITextField
在不是第一响应者时不能有游标.如果愿意,可以编写自定义的
There is no way to do that. However, in simulator you may press Cmd+K and that will dismiss keyboard but leave focus there (this is a simulation of hardware keyboard). But in general, UITextField
cannot have a cursor while not being a first responder. If you wish, you can write your custom one
这篇关于取消键盘后如何保持UITextField的光标焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!