I have a uitableview where each cell has a uitextfield. If i touch a text field low down in the table view, then it sets the text field as first responder and scrolls to it, and also scrolls up a keyboard (all as expected). But if the keyboard animation is faster than the table view scrolling, then the keyboard momentarily covers up the text field, which then therefore resigns as first responder.
It's hard to reproduce with a basic project or any code snippet that i could paste here, because the problem is that each cell is doing a lot of layout, and it's dequeueing other cells as it scrolls up etc, meaning that the scrolling is fairly slow.
I don't mind the slightly jerky scrolling, i'm just interested in finding a way of ensuring the text field keeps itself as first responder even when it momentarily is hidden by the keyboard.
edit:
as in the answer below, i'm now trying to maintain whether or not the table view is scrolling, and only allow resigning of first responder if scrolling = NO. The code for UITableViewDelegate is below, but the problem now is that non animated movements of the table view (i.e. scrollToRowAtIndexPath...animated:NO) result in scrollViewDidScroll, but not scrollViewDidEndScrollingAnimation. Any ideas on how to get round this in a way that isn't even more clunky?
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSLog(@"YES");
self.scrolling = YES;
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
NSLog(@"NO");
self.scrolling = NO;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"NO");
self.scrolling = NO;
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
NSLog(@"NO");
self.scrolling = NO;
}