iOS - How can I preload the keyboard? iOS - How can I preload the keyboard? ios ios

iOS - How can I preload the keyboard?


UIResponder+KeyboardCache was written to address this exact problem.

From that project's readme:

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.


making the textfield the firstResponder and then resigning it in the viewdidload.. this seems to work with no lag when the keyboard is loaded again...

- (void)viewDidLoad{    [super viewDidLoad];    [textField becomeFirstResponder];    [textField resignFirstResponder];        // Do any additional setup after loading the view, typically from a nib.}


Here's what I do:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  // Preloads keyboard so there's no lag on initial keyboard appearance.  UITextField *lagFreeField = [[UITextField alloc] init];  [self.window addSubview:lagFreeField];  [lagFreeField becomeFirstResponder];  [lagFreeField resignFirstResponder];  [lagFreeField removeFromSuperview];}

Super slow lag/delay on initial keyboard animation of UITextField