@@ -44,7 +44,7 @@ - (TPKeyboardAvoidingState*)keyboardAvoidingState {
44
44
45
45
- (void )TPKeyboardAvoiding_keyboardWillShow : (NSNotification *)notification {
46
46
CGRect keyboardRect = [self convertRect: [[[notification userInfo ] objectForKey: _UIKeyboardFrameEndUserInfoKey] CGRectValue ] fromView: nil ];
47
- if (CGRectIsEmpty (keyboardRect)) {
47
+ if (CGRectIsEmpty (keyboardRect) || ! CGRectIntersectsRect (keyboardRect, self. bounds ) ) {
48
48
return ;
49
49
}
50
50
@@ -76,11 +76,16 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
76
76
self.contentSize = [self TPKeyboardAvoiding_calculatedContentSizeFromSubviewFrames ];
77
77
}
78
78
}
79
-
79
+ int curve = [[[notification userInfo ] objectForKey: UIKeyboardAnimationCurveUserInfoKey] intValue ];
80
+ float duration = [[[notification userInfo ] objectForKey: UIKeyboardAnimationDurationUserInfoKey] floatValue ];
81
+ if (curve == 0 )
82
+ curve = 7 ;
83
+ if (duration == 0 )
84
+ duration = 0.25 ;
80
85
// Shrink view's inset by the keyboard's height, and scroll to show the text field/view being edited
81
86
[UIView beginAnimations: nil context: NULL ];
82
- [UIView setAnimationCurve: [[[notification userInfo ] objectForKey: UIKeyboardAnimationCurveUserInfoKey] intValue ] ];
83
- [UIView setAnimationDuration: [[[notification userInfo ] objectForKey: UIKeyboardAnimationDurationUserInfoKey] floatValue ] ];
87
+ [UIView setAnimationCurve: curve ];
88
+ [UIView setAnimationDuration: duration ];
84
89
85
90
self.contentInset = [self TPKeyboardAvoiding_contentInsetForKeyboard ];
86
91
@@ -90,7 +95,7 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
90
95
[self setContentOffset: CGPointMake (self .contentOffset.x,
91
96
[self TPKeyboardAvoiding_idealOffsetForView: firstResponder
92
97
withViewingAreaHeight: viewableHeight])
93
- animated: YES ];
98
+ animated: NO ];
94
99
95
100
96
101
[UIView commitAnimations ];
0 commit comments