問題描述
除其他外,我有一個帶有 UITextField 的應(yīng)用程序.當(dāng)用戶第一次點擊文本字段時,虛擬鍵盤出現(xiàn)之前會有明顯的延遲.在 3GS 上不是很明顯,但在舊款 iPhone 上延遲可能在 1 秒左右.之后,鍵盤總是會立即彈出.延遲只是應(yīng)用啟動后鍵盤第一次彈出.
I have an app with a UITextField, amongst other things. When the user first taps on the text field, there is a noticeable delay before the virtual keyboard appears. On a 3GS it isn't too obvious, but on an older iPhone the delay can be around 1 second. After that the keyboard always pops up instantly. The delay is only the first time the keyboard pops up after app startup.
看起來最初的 UIKeyboard 實例化需要一些時間(相當(dāng)多...),但在那之后會一直保留.
It looks like the initial UIKeyboard instantiation takes some time (quite a bit...) but is kept around after that.
我發(fā)現(xiàn)這方面的信息非常少,這讓我很驚訝.但是,我確實發(fā)現(xiàn)了這篇關(guān)于問題的文章以及一個破解解決方案.
I found very little information about this, which surprised me. However I did find this write up of the issue along with a hack-around solution.
http://blog.weareuproar.com/preloading-the-uikeyboard
我的問題是:這是唯一可用的解決方案嗎?有沒有辦法向框架發(fā)出信號(例如通過 info plist?)以在啟動時實例化鍵盤?
My question is: is this hack around the only available solution? Is there a way to signal the framework (e.g. via info plist?) to instantiate the keyboard on startup?
推薦答案
不,沒有其他(記錄的)方法可以做到這一點.甚至 Apple 的內(nèi)置應(yīng)用程序(如地圖)也面臨同樣的問題.您可以使用鏈接到的 hack,也可以遵循 Apple 的建議,在您真正需要之前不要提前加載內(nèi)容.順便說一句,這對于 iPhone 3Gs 和新的 iPod touch 來說已經(jīng)不是什么大問題了.更新更快的設(shè)備幾乎可以立即加載鍵盤.
No, there is no other (documented) way to do that. And even Apple's built-in apps (such as Maps) suffer from the same problem. You can either go with the hack you linked to or follow Apple's advice to not load stuff in advance before you really need it. By the way, this isn't much of an issue anymore with the iPhone 3Gs and the new iPod touch. The newer and faster devices load the keyboard almost instantly.
這篇關(guān)于UITextField 的初始 iPhone 虛擬鍵盤顯示速度很慢.是否需要這種黑客攻擊?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!