iOS - 如何预装键盘? [英] iOS - How can I preload the keyboard?

查看:72
本文介绍了iOS - 如何预装键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In most iPhone apps, there's a quite a bit of delay the first time that the keyboard is presented (presumably creating the keyboard takes quite a bit of oomph, even on an iPhone 4).

大多数人似乎都对此感到满意。我不是,它真的让我感到烦恼 - 以及我的应用程序呈现方式,用户会非常困惑,他们第一次点击文本字段时几秒钟内没有任何反应。

Most people seem ok with this. I'm not, it really bugs me - and the way my app is presented, users will be very confused that nothing happens for a few seconds when they tap on a text field for the first time.


谷歌搜索结果显示一个解决方案 - 不幸的是,从iOS 4开始这是无效的(请看这里)。

Googling it brings up one solution - unfortunately this is invalid as of iOS 4 (see here).

我不希望这个解决方案很容易找到,如果我可以直接给这个解决方案,我愿意。如果有人想出解决方案,我会非常激动。所有解决方案都需要在用户不知情的情况下加载键盘。

I don't expect the solution to be easy to find, if I could put a bounty on this straight away I would. I would be very stoked if someone figured out a solution. All the solution needs to do is load the keyboard without the user being aware.


任何想法都表示赞赏。完整的,有效的代码(适用于iOS 4和5)值得赏心悦目(即使赏金必须在以后!)。

Any ideas are appreciated. Complete, working code (for iOS 4 and 5) is bounty worthy (even if the bounty has to come later!).

如果找到解决方案,我打算创建一个自包含的'KeyboardPreloader'类,人们可以放入他们的项目,并用一行代码预加载键盘:)

If a solution is found I plan to create a self contained 'KeyboardPreloader' class that people can drop into their project, and preload the keyboard with one line of code :)

推荐答案

编写 UIResponder + KeyboardCache 是为了解决这个问题。

UIResponder+KeyboardCache was written to address this exact problem.

从该项目的自述文件:


此类别UIResponder 为您提供了一个简单的方法 + cacheKeyboard ,以便您可以控制何时完成此缓存工作。例如,如果要从服务器加载某些数据,则可以在该停机期间调用此数据。还有另一种方法 + cacheKeyboard:,它采用可选的 BOOL 值。将YES传递给此方法会导致缓存调用发生在 next runloop上。因此,如果您在调用此方法之前执行动画,则不会中断该动画。

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 - 如何预装键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆