I am using UITextField to receive user inputs. However, since my textfields are towards the middle/bottom of the nib, it gets hidden when the keyboard pops up. Is there any way sort of slide it along with the keyboard so that it's on the top of the keyboard during selection? Also, since I am also using the numberpad, is there an easy way to include a done button somewhere?
Thanks for the help.
When you click on the TextField it opens up the on-screen keyboard. To hide/dismiss the keyboard you have to press the back button in Android and the done button (inside the onscreen keyboard) in iOS.
If your keyboard is still stuck, even after you docked it, try restarting your iPad. We like using Settings > General > Shut Down and then power back up to restart all types of iPads, with or without home buttons.
A control that displays an editable text interface. iOS 13.0+ iPadOS 13.0+ macOS 10.15+ Mac Catalyst 13.0+ tvOS 13.0+ watchOS 6.0+
I have made a simple Application for this problem. It automatically checked the Textfield's position and if keyboard hides it , it will automatically move up as per need.
- (void)textFieldDidBeginEditing:(UITextField *)textField { [self animateTextField:textField up:YES]; } - (void)textFieldDidEndEditing:(UITextField *)textField { [self animateTextField:textField up:NO]; } - (void) animateTextField: (UITextField*) textField up: (BOOL) up { int animatedDistance; int moveUpValue = textField.frame.origin.y+ textField.frame.size.height; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { animatedDistance = 216-(460-moveUpValue-5); } else { animatedDistance = 162-(320-moveUpValue-5); } if(animatedDistance>0) { const int movementDistance = animatedDistance; const float movementDuration = 0.3f; int movement = (up ? -movementDistance : movementDistance); [UIView beginAnimations: nil context: nil]; [UIView setAnimationBeginsFromCurrentState: YES]; [UIView setAnimationDuration: movementDuration]; self.view.frame = CGRectOffset(self.view.frame, 0, movement); [UIView commitAnimations]; } } -(BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With