The iOS keyboard blocks the input box and the input area is automatically moved up.

Source: Internet
Author: User

The iOS keyboard blocks the input box and the input area is automatically moved up.
During iOS development, I encountered a problem about the keyboard shielding input box. After network reference and practice, I summarized the following: In the login window, two uitextfields, one user name and one password are placed up and down, placed at the bottom of the screen at 1/3. When you click the user name, the keyboard is automatically displayed, which blocks the solution of the input box: 1. BLoginViewController implements the UITextViewDelegate method to copy code 1 // implements the UITextFieldDelegate method. When the TextField is edited, that is, the keyboard pops up, the input box is automatically moved up to 2-(BOOL) usage :( UITextField *) textField {3 NSTimeInterval animationDuration = 0.30f; 4 [UIView beginAnimations: @ "ResizeForKeyboard" context: nil]; 5 [UIView setAnimationDuration: animationDuration] 6 float width = self. view. frame. size. width; 7 float height = self. view. frame. size. height; 8 // move up n units, set 9 CGRect rect = CGRectMake (0.0f,-130, width, height) according to the actual situation; 10 self. view. frame = rect; 11 [UIView commitAnimations]; 12 return YES; 13} copy code 2. Set proxy copy code 1-(void) viewDidLoad 2 {3 [super viewDidLoad] for the input box; 4 5 // status bar white font 6 [[UIApplication sharedApplication] setStatusBarStyle: Regular]; 7 8 UIColor * btnBgColor = [UIColor colorWithWhite: 1.0f alpha: 1.0]; 9 [_ buttonLogin setBackgroundColor: btnBgColor]; 10 11 // Add the proxy 12 _ textFieldUserName to the input box. delegate = self; 13 _ textFieldPassword. delegate = self; 14 15}

Related Article

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.