Skip to content

Commit c3116e2

Browse files
committed
Merge branch 'upstream'
lock during responder change causes weird animations inside the text fields, so it is an another workaround to solve the stuttering problem Conflicts: TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m
2 parents 7a89fc7 + 4a3aada commit c3116e2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
9494
animated:NO];
9595

9696
self.scrollIndicatorInsets = self.contentInset;
97+
[self layoutIfNeeded];
9798

9899
[UIView commitAnimations];
99100
}
@@ -125,6 +126,7 @@ - (void)TPKeyboardAvoiding_keyboardWillHide:(NSNotification*)notification {
125126
self.contentInset = state.priorInset;
126127
self.scrollIndicatorInsets = state.priorScrollIndicatorInsets;
127128
self.pagingEnabled = state.priorPagingEnabled;
129+
[self layoutIfNeeded];
128130
[UIView commitAnimations];
129131
}
130132

@@ -173,11 +175,11 @@ -(void)TPKeyboardAvoiding_scrollToActiveTextField {
173175
CGPoint idealOffset = CGPointMake(0, [self TPKeyboardAvoiding_idealOffsetForView:[self TPKeyboardAvoiding_findFirstResponderBeneathView:self]
174176
withViewingAreaHeight:visibleSpace]);
175177

176-
// Ordinarily we'd use -setContentOffset:animated:YES here, but it does not appear to
177-
// scroll to the desired content offset. So we wrap in our own animation block.
178-
[UIView animateWithDuration:0.25 animations:^{
179-
[self setContentOffset:idealOffset animated:NO];
180-
}];
178+
// Ordinarily we'd use -setContentOffset:animated:YES here, but it interferes with UIScrollView
179+
// behavior which automatically ensures that the first responder is within its bounds
180+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
181+
[self setContentOffset:idealOffset animated:YES];
182+
});
181183
}
182184

183185
#pragma mark - Helpers

0 commit comments

Comments
 (0)