Skip to content

Commit

Permalink
Merge branch 'upstream'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
michaeltyson committed Feb 4, 2015
2 parents 7a89fc7 + 4a3aada commit c3116e2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
animated:NO];

self.scrollIndicatorInsets = self.contentInset;
[self layoutIfNeeded];

[UIView commitAnimations];
}
Expand Down Expand Up @@ -125,6 +126,7 @@ - (void)TPKeyboardAvoiding_keyboardWillHide:(NSNotification*)notification {
self.contentInset = state.priorInset;
self.scrollIndicatorInsets = state.priorScrollIndicatorInsets;
self.pagingEnabled = state.priorPagingEnabled;
[self layoutIfNeeded];
[UIView commitAnimations];
}

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

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

#pragma mark - Helpers
Expand Down

0 comments on commit c3116e2

Please sign in to comment.