I have a table with each cell containing a label and a text field. Problem is that when i go to edit the last row, keyboard hides the lower portion of the table, and i can't see what is being typed. How can i move my interface above the keyboard so i see what is being typed?
Thanks, Mustafa
How To Change UITextField Keyboard Type In Xcode Attribute Inspector. Click the UITextField UI component in the Main.storyboard file to select it. Then click View —> Inspectors —> Show Attributes Inspector menu item at Xcode top menu bar. Scroll down to the Text Input Traits section, there are three drop-down lists related to the keyboard.
Then you can implement the textView function with the below source code. // This function is called when you input text in the textView. print("textView.") // If user press return key in the keyboard. // Resign first responder from UITextView to close the keyboard.
// Resign the first responder from textField to close the keyboard. To hide the keyboard when the user presses the return key on UITextView ‘s keyboard. We can add the below code in the textView function. You should first make your ViewController class implement the UITextViewDelegate delegate protocol.
So we can add the below code in the textFieldShouldReturn function to make the UITextField’s keyboard resign the first responder when pressing the return key. // This function is called when you click return key in the text field. // Resign the first responder from textField to close the keyboard.
You'll want to register your viewController for UIKeyboardDidShowNotification
and UIKeyboardWillHideNotification
events. When you get these, you should adjust the bounds of your table; the keyboard is 170 pixels height, so just shrink or grow your table bounds appropriately, and it should properly adjust to the keyboard.
This problem is complex depending on your UI scenario. Here I will discuss a scenario that where UITextField or UITextview resides in a UITableViewCell.
You need to use NSNotificationCenter to detect UIKeyboardDidShowNotification event. see http://iosdevelopertips.com/user-interface/adjust-textfield-hidden-by-keyboard.html. You need to shrink the UITableView frame size so that it occupies only the screen area that is not covered by the keyboard.
You need to call
[myTableView selectRowAtIndexPath:self.indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];`
to programmatically "tap" the cell.
If you implement both points, you will see the UITextView/Field position right above the keyboard. Bare in mind that the UITableViewCell where the UITableView/Field resides cannot be taller than the "not covered" area. If this is not the case for you, there is a different approach for it but I will not discuss here.
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