In the iOS development process, encountered on the keyboard occlusion input box problem, after network reference and practice, summarized as follows:
Login window, placed up and down two Uitextfield, a username, a password, placed in the bottom of the screen 1/3, when clicked on the user name, automatically eject the keyboard, just block the input box
Solution Ideas:
1, Bloginviewcontroller realization of Uitextviewdelegate method
1 //implements the method in Uitextfielddelegate, automatically moves the input box up when the keyboard pops up when the TextField is edited2-(BOOL) textfieldshouldbeginediting: (Uitextfield *) textfield{3Nstimeinterval animationduration=0.30f;4[UIView beginanimations:@"Resizeforkeyboard"Context:nil];5 [UIView setanimationduration:animationduration];6 floatwidth =Self.view.frame.size.width;7 floatHeight =Self.view.frame.size.height;8 //move n units up, set according to the actual situation9CGRect Rect=cgrectmake (0.0f,- the, width,height);TenSelf.view.frame=rect; One [UIView commitanimations]; A returnYES; -}
2. Set up an agent for the input box
1- (void) Viewdidload2 {3 [Super Viewdidload];4 5 //status bar White font6 [[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];7 8Uicolor *btnbgcolor = [Uicolor colorwithwhite:1.0fAlpha1.0];9 [_buttonlogin Setbackgroundcolor:btnbgcolor];Ten One //add an agent to the input box A_textfieldusername.Delegate=Self ; -_textfieldpassword.Delegate=Self ; - the}
Effect:
Reference: http://blog.csdn.net/ryantang03/article/details/8203605
iOS keyboard occlusion input box, input area automatically move up