I\'m using custom UITableViewCell
s inside my UITableView
. Each of these UITableViewCell
s is pretty high and contains a UITextFie
You can try doing the following:
self.tableView.scrollEnabled = NO;
This should disable the scrollview in the tableview.
Define properties for your UITableViewController
:
@property (nonatomic) BOOL scrollDisabled;
@property (nonatomic) CGFloat lastContentOffsetY;
Before you call becomeFirstResponder
:
// Save the table view's y content offset
lastContentOffsetY = tableViewController.tableView.contentOffset.y;
// Enable scrollDisabled
scrollDisabled = YES;
Add the following code to your table view controller:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (self.scrollDisabled) {
[self.tableView setContentOffset:CGPointMake(0, lastContentOffsetY)];
}
...
}
After you call resignFirstResponder
, set scrollDisabled = NO
.
You could disable the automatic content inset adjustment like so:
tableView.contentInsetAdjustmentBehavior = .never