iOS - 如何预加载键盘?

标签 ios objective-c performance uikeyboard

问题

在大多数 iPhone 应用程序中,第一次出现键盘时会有相当长的延迟(可能创建键盘需要相当长的时间,即使在 iPhone 4 上也是如此)。

大多数人似乎都可以接受。我不是,这真的让我很烦——而且我的应用程序的呈现方式,用户会很困惑,当他们第一次点击文本字段时,几秒钟内什么都没有发生。


我的尝试

谷歌搜索它带来了一种解决方案 - 不幸的是,这在 iOS 4 (see here) 中是无效的。

我不认为解决方案很容易找到,如果我可以立即为此提供赏金,我会的。如果有人想出解决方案,我会非常激动。解决方案所需要做的就是在用户不知情的情况下加载键盘。


所以..

任何想法都值得赞赏。完整的、可工作的代码(适用于 iOS 4 和 5)值得赏金(即使赏金必须稍后提供!)。

如果找到解决方案,我计划创建一个自包含的“KeyboardPreloader”类,人们可以将其放入他们的项目中,并使用一行代码预加载键盘:)

最佳答案

UIResponder+KeyboardCache是为了解决这个确切的问题而编写的。

来自该项目的自述文件:

This category on UIResponder gives you a simple method +cacheKeyboard so that you can control when this caching work is done. For example, if you are loading some data from a server, then you could invoke this during that downtime. There is another method +cacheKeyboard: that takes an optional BOOL value. Passing YES to this method causes the cache invocation to happen on the next runloop. So, if you performed an animation just before calling this method it would not interrupt that animation.

关于iOS - 如何预加载键盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9108245/

相关文章:

performance - epoll整合的优势

ios - 当一个属性是只读的时候,copy 和 nonatomic 就没有意义了吗?

iphone - 带阴影的分组 uitableview

objective-c - ios堆栈溢出中的uuid,udid和设备 token 有什么区别

ios - 无法安装 Crashlytics

python - 在 python 中使用 try except - 成本是多少?

MySQL SELECT * 究竟是如何工作的 MySQL/Query Efficiency

ios - AVAudioRecorder消除低声音

ios - 重用 Storyboard和 uicontrollers

iphone - iOS 中基于 URL 的导航,例如 three20 的 TTNavigator