iOS custom keyboard and system keyboard toggle and text input box always gets focus

Source: Internet
Author: User

Uitextview is used for text input.
Methods Becomefirstresponder and Resignfirstresponder can be used to eject the system keyboard and to accept the system keyboard.

The system keyboard pops up and the text input box gets focus. Accept the system keyboard and the text input box loses focus. So, here's the problem.

Under certain conditions, such as clicking on a button on the interface, the custom keyboard is displayed. Tap again to switch to the system keyboard.
Accept the system keyboard first and then display the custom keyboard. For example, move the frame.y of a custom keyboard view. However, because the system keyboard is received, the input box in this article loses focus.
Although the custom keyboard is displayed. But the user experience is not good. The cursor is not flashing. The contents of the custom keyboard input cannot be inserted into the text input box accurately.

Workaround: (see iOS development documentation)

@property (ReadWrite, retain) UIView *inputview

If The value is nil, the text view displays the standard system keyboard when it becomes first responder. Assigning a custom view to the This property causes the view to be presented instead.

The default value of the is nil.

This property means
1. Display the system keyboard for nil.
2. Show custom keyboard for custom view.

Note to refresh.

-(void) reloadinputviews

Can use this method to refresh the custom input view or input accessory view associated with the current object when I T is the first responder. The views were replaced Immediately-that is, without animating them to place. If the current object isn't the first responder, this method has no effect.

Solve the problem perfectly.
The text input box always gets the focus. Customize keyboard and system keyboard to switch freely.

iOS custom keyboard and system keyboard toggle and text input box always gets focus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.