Search code examples
iosiphoneanimationkeyboard

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


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 call [someTextView becomeFirstResponder] in viewWillAppear, the keyboard immediatly pops up with no animation. And when I call it in viewDidAppear, the view first slides in from the right (UINavigationController does the sliding), and then the keyboard slides in from the bottom.

Is it possible to have the keyboard slide in from the right, together with the view?


Solution

  • All you need to do is tell the text view in question to become the first responder in the viewDidLoad method of the view controller you're pushing onto the navigation stack:

    override func viewDidLoad() {
        super.viewDidLoad()
        someTextView.becomeFirstResponder()
    }
    

    This works in iOS 8. The keyboard slides in from the right along with the view.