A problem is found in iOS development. Sometimes when the input box is low, when the input is edited, the pop-up keyboard will block the input box, so that users cannot see the real-time input, make interface interaction extremely unfriendly.
After checking the information, the problem was finally solved.
Solution:
1. input box listeningUicontroleventeditingdidbegin event,When the user starts to input, the entire view is moved up.
2. input box listeningUicontroleventeditingdidend event,When the user finishes the input, the entire view is moved down and restored to the original position.
Input box listening event:
[Textfield addtarget: Self action: @ selector (textfielddidbeginediting :) forcontrolevents: Inputs]; [textfield addtarget: Self action: @ selector (textfielddidendediting :) forcontrolevents: Inputs];
RESPONSE event:
-(Void) textfielddidbeginediting :( uitextfield *) textfield {// when you start editing, move the entire if (textfield. tag = 0) {[self moveview:-20];} If (textfield. tag = 1) {[self moveview:-60] ;}}-(void) textfielddidendediting :( uitextfield *) textfield {// when editing ends, the overall move down if (textfield. tag = 0) {[self moveview: 20];} If (textfield. tag = 1) {[self moveview: 60] ;}}-(void) moveview :( float) move {nstimeinterval animationduration = 0.30f; cgrect frame = self. view. frame; frame. origin. X + = move; // the X axis of the view moves up self. view. frame = frame; [uiview beginanimations: @ "resizeview" context: Nil]; [uiview setanimationduration: animationduration]; self. view. frame = frame; [uiview commitanimations]; // set and adjust the animation effect on the Interface}
When there are several input boxes, the tag attribute of the input box is used to determine which input box the user has clicked, provided that you must assign a value to the tag first. This method is particularly effective for the embedded dialog boxes in tableview.
Another way is to know the names of input boxes and use the names to determine which input boxes the user has clicked.
Only when the user clicks the input box can the distance to be moved in the input box be determined.