Summary of the invention
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 is created in the classification of controller and calls function, the first call back function and the second call back function, and fixed
The justice keyboard parameter calls the parameter of function;It includes keyboard coordinate value parameter, key that the keyboard parameter, which calls the parameter of function,
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;
It calls function to obtain the notice center of system by keyboard parameter 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;
Controller receive keyboard notice after, using the state that keyboard action function obtains current keyboard be pop-up or it is hidden
Hiding, and call 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
Hiding.
Based on the above technical solution, the keyboard coordinate value parameter includes coordinate value before keyboard changes, keyboard bullet
Whether the time and current keyboard needed out pops 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 change before coordinate value, keyboard pop-up need when
Between and keyboard action terminate parameter and adjusted back using the first call back function to controller;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 using the second call back function to controller.
Based on the above technical solution, the keyboard parameter calls function call notice management class
The method that NSNotificationCenter calls acquisition system notice obtains 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, store on memory in processor
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, comprising:
Function creation module is used to create keyboard parameter in the classification of controller and calls function, the first call back function
With the second call back function, and the parameter that the keyboard parameter calls function is defined;The keyboard parameter calls the parameter packet of function
Including keyboard coordinate value parameter, keyboard position running parameter and keyboard action 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 call function to obtain the notice center of system by keyboard parameter 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, obtains current key 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 changes, keyboard bullet
Whether the time and current keyboard needed out pops 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
It is pop-up or hiding, the coordinate before obtaining keyboard variation in keyboard notice with the state that keyboard action function obtains current keyboard
The time and keyboard action that value, keyboard pop-up need are terminated parameter and are adjusted back using the first call back function to controller;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 using the second call back function to controller.
Based on the above technical solution, the parameter acquisition module manages class for call notification
The method that NSNotificationCenter calls acquisition system notice obtains 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 by the classification in controller and calls function and the first call back function and second time
Letter of transfer number, it is only necessary to the keyboard of monitoring system notifies, the parameter in the keyboard listened to notice 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 hiding 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 embodiment
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 is created in the classification of controller and calls function, the first call back function and the second call back function, and fixed
Adopted keyboard parameter calls the parameter of function;It includes keyboard coordinate value parameter, keyboard position change that keyboard parameter, which calls the parameter of function,
Changing 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;
It calls function to obtain the notice center of system by keyboard parameter 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;
Controller receive keyboard notice after, using the state that keyboard action function obtains current keyboard be pop-up or it is hidden
Hiding, and call 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 by the classification in controller and calls function and the first call back function and second time
Letter of transfer number, it is only necessary to the keyboard of monitoring system notifies, the parameter in the keyboard listened to notice 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 hiding 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, creation keyboard parameter calls function, the first call back function and the second call back function, and definition keyboard parameter tune
With the parameter of function the specific implementation process is as follows:
1) keyboard parameter calls the statement of function
Definition keyboard parameter calls the statement of function, and the name of this function is an_subscribeAnimations, this
A function needs three parameters,
First parameter is that type is KeyboardBlock type, 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 type, and corresponding call back function is the second readjustment
Function, the title of the second call back function are animations;
Third parameter is that keyboard action terminates parameter, a CompletAnimationBlock type.
2) realization that keyboard parameter calls function is write
The statement of this function is completed above, is write the realization of this function now, is inside this function of creation
It is realized by classifying.It is because many keyboards, which need the page popped up, to be needed using key 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 using we
Case.Method particularly includes: three incoming above parameters are all saved using the method for affiliated partner inside this function.
Because attribute can not be added in classification to generate set method and get method, only realized using the method for affiliated partner.
Controller receive keyboard notice after, using the state that keyboard action function obtains current keyboard be pop-up or it is hidden
Hiding, the time and keyboard action that coordinate value, keyboard pop-up need before obtaining keyboard variation in keyboard notice terminate parameter and make
It is adjusted back with the first call back function to controller;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 change 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 type before keyboard changes;
The time that keyboard pop-up needs is the duration of NSTimeInterval type;
Current keyboard whether pop up be Boolean type isShowing;
Coordinate value is the rect of CGRect type after keyboard variation;
The time that change in location needs is the duration of NSTimeInterval type;
Keyboard action terminates the finished that parameter is Boolean type.
It is needed at this time using the method for obtaining affiliated partner from coordinate value, keyboard pop-up before acquisition keyboard variation in keyboard notice
The time and keyboard action wanted terminate parameter, and the method for obtaining affiliated partner is objc_getAssociatedObject.
Keyboard parameter calls function call notice management class NSNotificationCenter to call acquisition system notice
Method obtains the notice center of system, monitors keyboard using addObserver function and notifies.
Specifically, it goes to monitor using addObserver function 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, comprising:
Function creation module is used to create keyboard parameter in the classification of controller and calls function, the first call back function
With the second call back function, and definition keyboard parameter call function parameter;It includes that keyboard is sat that keyboard parameter, which calls the parameter of function,
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 call function to obtain the notice center of system by keyboard parameter 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, obtains current key 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 change 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, obtains current keyboard 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
Movement is terminated parameter and is adjusted back using the first call back function to controller;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 calls acquisition system notice for call notification management class NSNotificationCenter
Method obtains the notice center of system, monitors keyboard using addObserver function and 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 protection of the invention
Within the scope of.The content being not described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.