iPhone - Have the keyboard slide into view from the right like when editing a note in Contacts

前端 未结 5 1762
轻奢々
轻奢々 2020-12-30 01:33

I\'m looking for a way to slide the keyboard into view from the right, like what happens in the Contacts application when you edit a note.

My problem is that when I

5条回答
  •  庸人自扰
    2020-12-30 02:38

    For iOS 7 I've found the following solution to work the best for me:

    -Import UIResponder-KeyboardCache to your project.

    -Add [UIResponder cacheKeyboard:YES]; to the viewDidLoad of the view before the keyboard view. It might be better to do this immediately when the application loads or during a time convenient when you can afford it (during an HTTP request, for example). In most cases, simply in the view before is sufficient.

    -Add the following to the viewDidLoad of the keyboard view.

    dispatch_async(dispatch_get_main_queue(), ^{
      [_textField becomeFirstResponder];
    });
    

    To explain, this will preload the keyboard view, which will remove the delay from the first call of the keyboard view. Calling becomeFirstResponder on the text field in the main queue causes it to slide in with the view instead of animating upward before the view slides in.

提交回复
热议问题