Observer pattern parsing in keyboard projects

Source: Internet
Author: User

This project is designed to solve problems where the floppy and input box locations do not match when the input box is nested in multiple layers. the GitHub source link for the project is: https://github.com/crazycodeboy/KeyboardObserver/blob/master/KeyboardObserver/ KEYBOARDOBSERVER.M first, the observer pattern implementation principleThe Observer pattern defines a one-to-many dependency that allows multiple observer objects to listen to a Subject object at the same time. When the subject object changes in state, all observer objects are notified so that they can update themselves. In this project, its implementation principle is mainly embodied in the following operations: -(void)addGlobalKeyboardObserver
Add a keyboard viewer to all the input boxes in the interface,Add the listener to the event source,The ENTER key listens, touches the other area listens. Realizewhen the floppy disk pops up to automatically control the display position of the input box to prevent it from being obscured by the floppy disk, the floppy disk is hidden and the interface is restored when the key is outside the touch input box or when you press the ENTER key.
-(void)removeGlobalKeyboardObserver
Removes the keyboard viewer from all input boxes in the interface.
-(void)addKeyboardObserver
Adds a keyboard viewer to the specified input box,Add the listener to the event source,The ENTER key listens, touches the other area listens.realize when the floppy disk eject automatically control the display position of the input box to prevent being obscured by the floppy disk, when the touch input box outside the position or press the floppy key, the floppy disk hidden, interface recovery.
-(void)removeKeyboardObserver
Removes the keyboard observer for the specified input box.
-(void)addSimpleKeyboardObserver
Adds a keyboard viewer to the specified input box,Add the listener to the event source,Touch other areas to listen.implement automatic control of the display position of the input box when the floppy disk pops up to prevent it from being obscured by a floppy disk, hide the floppy disk when it is outside the touch input box or press the return key of the floppy disk, and restore the interface.。
-(void)removeKeyboardObserver
Removes the keyboard observer for the specified input box. -(void)registerKeyboardNotificationsEvent Source Change trigger event (specific subject role status change, notify Observer). -(void)removeKeyboardNotificationsremoves the listener from the event source and no longer triggers the event. second, the role of the Observer model 1. Automatically control the display position of the input box when the floppy disk pops up to prevent the floppy disk from being obscured.
2. The floppy disk is hidden and the interface is restored when the key is outside the touch input box or when you press the return key of the floppy disk.
3. Support to add monitoring and removal of all input boxes to the entire page.
4. Support for adding monitoring and removing listeners for the specified input box.
5. Simple to use, a single line of code to complete the listening configuration.

Observer pattern parsing in keyboard projects

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.