Invention content
In view of the deficiencies in the prior art, the purpose of the present invention is to provide a kind of keyboard optimized treatment method, deposit
Storage media, electronic equipment and system simplify and monitor the code developed needed for notice using mobile phone mobile terminal application software.
To achieve the above objectives, the technical solution adopted by the present invention is that:A kind of keyboard optimized treatment method:
Keyboard parameter call function, the first call back function and the second call back function are created in the classification of controller, and fixed
The parameter of the justice keyboard parameter call function;The parameter of the keyboard parameter call function includes keyboard coordinate value parameter, key
Disk change in location parameter and keyboard action terminate parameter;First call back function is used to adjust back the keyboard coordinate value parameter,
Second call back function is for adjusting back the keyboard position running parameter;
The notice center of system is obtained by keyboard parameter call function and monitors keyboard notice, then the keyboard that will be listened to
Notice feeds back to the classification of the controller by callback method, and each controller is allowed to be multiplexed;
After controller receives keyboard notice, state that current keyboard is obtained using keyboard action function is pop-up or hidden
It hides, and calls first call back function and the second call back function to realize the pop-up of keyboard or hidden according to the keyboard notice received
It hides.
Based on the above technical solution, the keyboard coordinate value parameter includes coordinate value before keyboard variation, keyboard bullet
Whether the time and current keyboard for going out needs pop up;Keyboard position running parameter includes coordinate value and position change after keyboard variation
Change the time needed;Keyboard action terminates parameter for indicating that keyboard pop-up or hide actions terminate.
Based on the above technical solution, after controller receives keyboard notice, worked as using the acquisition of keyboard action function
The state of preceding keyboard be pop-up or hide, from keyboard notice in obtain keyboard variation before coordinate value, keyboard pop-up need when
Between and keyboard action terminate parameter and adjusted back to controller using the first call back function;After obtaining keyboard variation in keyboard notice
The time that coordinate value, change in location need, and coordinate value, change in location need after keyboard is changed time and current keyboard
State is to pop up or hide to adjust back to controller using the second call back function.
Based on the above technical solution, the keyboard parameter call function call notification manages class
NSNotificationCenter calls the method for obtaining notifications to obtain the notice center of system, uses addObserver
Function monitors keyboard notice.
The invention also discloses a kind of storage medium, computer program, the computer journey are stored on the storage medium
Keyboard optimized treatment method is realized when sequence is executed by processor.
The invention also discloses a kind of electronic equipment, including memory and processor, stored in processor on memory
The computer program of upper operation, processor realize keyboard optimized treatment method when executing computer program.
The invention also discloses a kind of keyboard optimization processing systems, including:
Function creation module is used to create keyboard parameter call function, the first call back function in the classification of controller
With the second call back function, and the parameter of the keyboard parameter call function is defined;The parameter packet of the keyboard parameter call function
It includes keyboard coordinate value parameter, keyboard position running parameter and keyboard action and terminates parameter;First call back function is for adjusting back
The keyboard coordinate value parameter, second call back function is for adjusting back the keyboard position running parameter;
Parameter acquisition module is used to obtain the notice center of system by keyboard parameter call function and monitors keyboard and leads to
Know, then the keyboard listened to notice is fed back to the classification of the controller by callback method, each controller is allowed to be multiplexed;
Keyboard action module, is used for after controller receives keyboard notice, and current key is obtained using keyboard action function
The state of disk is pop-up or hides, and calls first call back function and the second call back function according to the keyboard notice received
It realizes the pop-up of keyboard or hides.
Based on the above technical solution, the keyboard coordinate value parameter includes coordinate value before keyboard variation, keyboard bullet
Whether the time and current keyboard for going out needs pop up;Keyboard position running parameter includes coordinate value and position change after keyboard variation
Change the time needed;Keyboard action terminates parameter for indicating that keyboard pop-up or hide actions terminate.
Based on the above technical solution, the parameter acquisition module is used for after controller receives keyboard notice, is made
The state that current keyboard is obtained with keyboard action function is pop-up or hides, from coordinate before acquisition keyboard variation in keyboard notice
The time and keyboard action that value, keyboard pop-up need are terminated parameter and are adjusted back to controller using the first call back function;From keyboard
Coordinate value after keyboard variation is obtained in notice, the time that change in location needs, and coordinate value, change in location need after keyboard is changed
The state of the time and current keyboard wanted are to pop up or hide to adjust back to controller using the second call back function.
Based on the above technical solution, the parameter acquisition module manages class for call notification
NSNotificationCenter calls the method for obtaining notifications to obtain the notice center of system, uses addObserver
Function monitors keyboard notice.
Compared with the prior art, the advantages of the present invention are as follows:
The present invention creates keyboard parameter call function and the first call back function and second time by the classification in controller
Letter of transfer number, it is only necessary to the keyboard of monitoring system notifies that the parameter in notifying the keyboard listened to is adjusted back to the classification of controller,
Allow each controller to be multiplexed, then the pop-up of keyboard and hidden is realized by the first call back function and the second call back function and controller
The everything of Tibetan is monitored keyboard pop-up and hiding event without defining a notice in each controller, is simplified
The code developed needed for notice is monitored using mobile phone mobile terminal application software.
Specific implementation mode
Invention is further described in detail with reference to the accompanying drawings and embodiments.
Shown in Figure 1, the embodiment of the present invention provides a kind of keyboard optimized treatment method:
Keyboard parameter call function, the first call back function and the second call back function are created in the classification of controller, and fixed
The parameter of adopted keyboard parameter call function;The parameter of keyboard parameter call function includes keyboard coordinate value parameter, keyboard position change
Change parameter and keyboard action terminates parameter;For adjusting back keyboard coordinate value parameter, the second call back function is used for first call back function
Adjust back keyboard position running parameter;
The notice center of system is obtained by keyboard parameter call function and monitors keyboard notice, then the keyboard that will be listened to
Notice feeds back to the classification of controller by callback method, and each controller is allowed to be multiplexed;
After controller receives keyboard notice, state that current keyboard is obtained using keyboard action function is pop-up or hidden
It hides, and calls the first call back function and the second call back function to realize the pop-up of keyboard or hide according to the keyboard notice received.
The present invention creates keyboard parameter call function and the first call back function and second time by the classification in controller
Letter of transfer number, it is only necessary to the keyboard of monitoring system notifies that the parameter in notifying the keyboard listened to is adjusted back to the classification of controller,
Allow each controller to be multiplexed, then the pop-up of keyboard and hidden is realized by the first call back function and the second call back function and controller
The everything of Tibetan is monitored keyboard pop-up and hiding event without defining a notice in each controller, is simplified
The code developed needed for notice is monitored using mobile phone mobile terminal application software.
Wherein, keyboard parameter call function, the first call back function and the second call back function, and definition keyboard parameter tune are created
With the parameter of function the specific implementation process is as follows:
1) statement of keyboard parameter call function
The name of the statement of definition keyboard parameter call function, this function is an_subscribeAnimations, this
A function needs three parameters,
First parameter is that type is KeyboardBlock types, and corresponding call back function is the first call back function, the
The title of one call back function is beforeAnimations;
The type of second parameter is AnimationBoardBlock types, and corresponding call back function is the second readjustment
The title of function, the second call back function is animations;
Third parameter is that keyboard action terminates parameter, a CompletAnimationBlock type.
2) realization of keyboard parameter call function is write
The statement of this function is completed above, is write the realization of this function now, is inside this function of establishment
It is realized by classifying.It is because it is to need to use key that many keyboards, which need the page popped up, herein why using classification
Disk, a classification based on controller is created, all controllers is allowed to call, can be more convenient and more efficiently use we
Case.Specific method is:Three incoming above parameters are all saved using the method for affiliated partner inside this function.
Because attribute can not be added to generate set methods and get methods in classification, only realized using the method for affiliated partner.
After controller receives keyboard notice, state that current keyboard is obtained using keyboard action function is pop-up or hidden
It hides, the time and keyboard action that coordinate value, keyboard pop-up need before obtaining keyboard variation in keyboard notice terminate parameter and makes
It is adjusted back to controller with the first call back function;From keyboard notice in obtain keyboard variation after coordinate value, change in location need when
Between, and the state of coordinate value, the time that change in location needs and current keyboard is that pop-up or hide uses after keyboard is changed
Second call back function is adjusted back to controller.
Keyboard coordinate value parameter include keyboard variation before coordinate value, keyboard pop-up need time and current keyboard whether
Pop-up;Keyboard position running parameter includes the time of coordinate value and change in location needs after keyboard variation;Keyboard action terminates to join
Number is for indicating that keyboard pop-up or hide actions terminate.
Wherein:
Coordinate value is the rect of CGRect types before keyboard variation;
The time that keyboard pop-up needs is the duration of NSTimeInterval types;
Current keyboard whether pop up be Boolean type isShowing;
Coordinate value is the rect of CGRect types after keyboard variation;
The time that change in location needs is the duration of NSTimeInterval types;
Keyboard action terminates the finished that parameter is Boolean type.
It is needed at this time from coordinate value, keyboard pop-up before acquisition keyboard variation in keyboard notice using the method for obtaining affiliated partner
The time and keyboard action wanted terminate parameter, and the method for obtaining affiliated partner is objc_getAssociatedObject.
Keyboard parameter call function call notification manages class NSNotificationCenter and calls acquisition notifications
Method obtains the notice center of system, and monitoring keyboard using addObserver functions notifies.
Specifically, it goes to monitor using addObserver functions and notify, monitor notice and need a notice name, need to add
Add listener, who is exactly set and monitors this notice, be set as self, self represents current controller and monitors this notice.
Notify that name is UIKeyboardWillShowNotification, the readjustment received is ShowNotification;Notifying name is
UIKeyboardWillHideNotification, the readjustment received are handleNotification.
The embodiment of the invention also discloses a kind of storage medium, computer program, computer are stored on the storage medium
Keyboard optimized treatment method is realized when program is executed by processor.
The embodiment of the invention also discloses a kind of electronic equipment, including memory and processor, stored on memory
The computer program run on processor, processor realize keyboard optimized treatment method when executing computer program.
Shown in Figure 2, the embodiment of the invention also discloses a kind of keyboard optimization processing systems, including:
Function creation module is used to create keyboard parameter call function, the first call back function in the classification of controller
With the second call back function, and the parameter of definition keyboard parameter call function;The parameter of keyboard parameter call function includes that keyboard is sat
Scale value parameter, keyboard position running parameter and keyboard action terminate parameter;First call back function is for adjusting back keyboard coordinate value ginseng
Number, the second call back function is for adjusting back keyboard position running parameter;
Parameter acquisition module is used to obtain the notice center of system by keyboard parameter call function and monitors keyboard and leads to
Know, then the keyboard listened to notice is fed back to the classification of controller by callback method, each controller is allowed to be multiplexed;
Keyboard action module, is used for after controller receives keyboard notice, and current key is obtained using keyboard action function
The state of disk is pop-up or hides, and calls the first call back function and the second call back function to realize according to the keyboard notice received
The pop-up of keyboard is hidden.
Keyboard coordinate value parameter include keyboard variation before coordinate value, keyboard pop-up need time and current keyboard whether
Pop-up;Keyboard position running parameter includes the time of coordinate value and change in location needs after keyboard variation;Keyboard action terminates to join
Number is for indicating that keyboard pop-up or hide actions terminate.
Parameter acquisition module is used for after controller receives keyboard notice, and current keyboard is obtained using keyboard action function
State is pop-up or hides, from the time and keyboard that coordinate value, keyboard pop-up need before acquisition keyboard variation in keyboard notice
Action is terminated parameter and is adjusted back to controller using the first call back function;From keyboard notice in obtain keyboard variation after coordinate value,
The time that change in location needs, and the state of coordinate value, the time that change in location needs and current keyboard is after keyboard is changed
Pop-up, which is still hidden, is adjusted back using the second call back function to controller.
Parameter acquisition module is called for call notification management class NSNotificationCenter and obtains notifications
Method obtains the notice center of system, and monitoring keyboard using addObserver functions notifies.
The present invention is not limited to the above-described embodiments, for those skilled in the art, is not departing from
Under the premise of the principle of the invention, several improvements and modifications can also be made, these improvements and modifications are also considered as the protection of the present invention
Within the scope of.The content not being described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.