@@ -57,8 +57,6 @@ @interface UIMessageInputView () <AGEmojiKeyboardViewDelegate, AGEmojiKeyboardVi
5757@property (strong , nonatomic ) MBProgressHUD *HUD;
5858@property (strong , nonatomic ) NSString *uploadingPhotoName;
5959
60- @property (nonatomic , assign ) CGFloat curKeyboardEndFrameY;
61-
6260@end
6361
6462@implementation UIMessageInputView
@@ -139,8 +137,6 @@ - (id)initWithFrame:(CGRect)frame
139137 // Initialization code
140138 self.backgroundColor = [UIColor colorWithHexString: @" 0xf8f8f8" ];
141139 [self addLineUp: YES andDown: NO andColor: [UIColor lightGrayColor ]];
142- _curKeyboardEndFrameY = -1 ;
143-
144140 _viewHeightOld = CGRectGetHeight (frame);
145141 _inputState = UIMessageInputViewStateSystem;
146142 _isAlwaysShow = NO ;
@@ -869,29 +865,30 @@ - (void)keyboardChange:(NSNotification*)aNotification{
869865 if (self.inputState == UIMessageInputViewStateSystem && [self .inputTextView isFirstResponder ]) {
870866 NSDictionary * userInfo = [aNotification userInfo ];
871867 CGRect keyboardEndFrame = [[userInfo objectForKey: UIKeyboardFrameEndUserInfoKey] CGRectValue ];
872- if (_curKeyboardEndFrameY == keyboardEndFrame.origin .y ) {
868+ CGFloat keyboardY = keyboardEndFrame.origin .y ;
869+
870+ CGFloat selfOriginY = keyboardY == kScreen_Height ? self.isAlwaysShow ? kScreen_Height - CGRectGetHeight (self.frame ): kScreen_Height : keyboardY - CGRectGetHeight (self.frame );
871+ // if (keyboardY == kScreen_Height) {
872+ // if (self.isAlwaysShow) {
873+ // selfOriginY = kScreen_Height- CGRectGetHeight(self.frame);
874+ // }else{
875+ // selfOriginY = kScreen_Height;
876+ // }
877+ // }else{
878+ // selfOriginY = keyboardY-CGRectGetHeight(self.frame);
879+ // }
880+ if (selfOriginY == self.frame .origin .y ) {
873881 return ;
874- }else {
875- _curKeyboardEndFrameY = keyboardEndFrame.origin .y ;
876882 }
877-
883+
884+
885+ __weak typeof (self) weakSelf = self;
878886 void (^endFrameBlock)() = ^(){
879- CGFloat keyboardY = keyboardEndFrame.origin .y ;
880- if (ABS (keyboardY - kScreen_Height ) < 0.1 ) {
881- if (_isAlwaysShow) {
882- [self setY: kScreen_Height - CGRectGetHeight (self .frame)];
883- }else {
884- [self setY: kScreen_Height ];
885- }
886- }else {
887- [self setY: keyboardY-CGRectGetHeight (self .frame)];
888- }
887+ [weakSelf setY: selfOriginY];
889888 };
890-
891889 if ([aNotification name ] == UIKeyboardWillChangeFrameNotification) {
892890 NSTimeInterval animationDuration = [[userInfo objectForKey: UIKeyboardAnimationDurationUserInfoKey] doubleValue ];
893891 UIViewAnimationCurve animationCurve = [[userInfo objectForKey: UIKeyboardAnimationCurveUserInfoKey] intValue ];
894-
895892 [UIView animateWithDuration: animationDuration delay: 0 .0f options: [UIView animationOptionsForCurve: animationCurve] animations: ^{
896893 endFrameBlock ();
897894 } completion: nil ];
0 commit comments