On a multiple input interface, there will be more than one Uitextfield type of input box. In order to scroll, we will add them to the UITableView cell to form a data entry interface that can slide up and down.
But character input is done by the system automatically pops up the soft keyboard, so when you select the cell at the bottom of the screen, it is covered by the soft keyboard area.
Similarly, because the input box is in the UITableView cell, you can scroll the cell in place on top of the soft pad-covered area. So that we can see the input box.
Now, we're going to implement this process.
We can simply scroll the cell to the top of the visible area of the table view.
UITableView provides this method of "scrollToRowAtIndexPath:atScrollPosition:animated:". As a first responders ' input box, it can be delegated by its method-(void) textfielddidbeginediting: (uitextfield*) TextField
Assign the value to a variable Lastedittextfield. The appearance and disappearance of the soft keyboard are registered in the View controller class and the method of implementing it. In this way, when the Uitextfield activates the eject keyboard, the system automatically submits a soft keyboard pop-up notification. A keyboard pop-up notification invokes a method.
The logic of this method is to get the cell that operates according to the location where Lastedittextfield is located, and then to scroll the cell to the top of the view visible area.
Cgpoint PT =lastedittextfield.center;
PT = [Self.tableview ConvertPoint:ptfromView:lastEditTextField.superview];
nsindexpath* Indexpath = [SELF.TABLEVIEWINDEXPATHFORROWATPOINT:PT];
[Self.tableview ScrollToRowAtIndexPath:indexPathatScrollPosition:UITableViewRowAnimationTop Animated:yes];
The most important thing in this code is to use the UIView instance Method-(Cgpoint) Convertpoint: (cgpoint) point Fromview according to the value of Lastedittextfield.center: (UIView *) View converts it to a value under the Self.tableview coordinate system. According to the value of lastedittextfield.center in the new coordinate system, the UITableView instance method is used to scrollToRowAtIndexPath:atScrollPosition:animated: Scroll the cell to the top of the screen.
When the keyboard disappears, the system sends another notification and restores the screen to its original location.
Scroll the input box to the top, although it meets our input visibility requirements. However, if you can only scroll to the top of the soft keyboard, rather than the top of the UITableView, you do not need to scroll when the input box is not in the area covered by the keyboard. Such a deal would be a more satisfying result.