Skip to content

Commit

Permalink
Update UIScrollView+TPKeyboardAvoidingAdditions.m
Browse files Browse the repository at this point in the history
Stable work on iOS 10. I observed periodic problems when the text field was shifted upwards. Sometimes the text field shifts up, and sometimes it does not. This commit fixes this bug.
  • Loading branch information
RunesReader authored Mar 23, 2017
1 parent c30c491 commit 86f15a6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

static const CGFloat kCalculatedContentPadding = 10;
static const CGFloat kMinimumScrollOffsetPadding = 20;
static const CGFloat kAnimationDuration = 0.25;

static const int kStateKey;

Expand Down Expand Up @@ -217,11 +218,10 @@ -(void)TPKeyboardAvoiding_scrollToActiveTextField {

// 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];

[UIView animateWithDuration:kAnimationDuration animations:^{
self.contentOffset = idealOffset;
state.ignoringNotifications = NO;
});
}];
}

#pragma mark - Helpers
Expand Down

0 comments on commit 86f15a6

Please sign in to comment.