I have a UITableView
that contains UITextField
in each cell
When I click UITextField
in the cell, the keyboard will show and cover my cell. Therefore, I move my cell to the top by using.
- (void)keyboardWasShown:(NSNotification*)aNotification
{
CGPoint scrollPoint = CGPointMake(0, self.activeInputView.frame.origin.y);
[self.tableView setContentOffset:scrollPoint animated:YES];
}
If I use single click on each cell, my application work fine.
However, I use double click on each cell (it mean I tap on it 2 times very quickly), my cell will stop scroll to the top.
For example, many developers make their life harder using a scroll view when a UITableView would be a better choice. Finally, architecture is crucial for table views. The code of the table view data source often ends inside view controllers when it should go into a separate class.
The cells of UITableView are instances of UITableViewCell or its subclasses. It is the table view that adds, removes, and arranges cells in its view hierarchy. Table views reuse cells that go out of the screen to display new elements, so that:
Table views are more versatile than you might think. For example, many developers make their life harder using a scroll view when a UITableView would be a better choice. Finally, architecture is crucial for table views.
Were you using a UITableViewController? One of the few things it does is call reloadData () on the table view. Now you have to do it yourself. Place it after you assign the data source to the table view.
In this line
CGPoint scrollPoint = CGPointMake(0, self.activeInputView.frame.origin.y);
can be 2 errors.
Firstly, you have to make sure that inputView that you have captured is the view you want. Secondly, you should convert fetched point to correct view using appropriate method.
See reference: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/doc/uid/TP40006816-CH3-SW52
For further investigation need more context.
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