Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用uitabbarcontroller之后,点击评论弹出键盘,输入框被键盘遮盖,手动改变_inputView的 Y 值无效 #21

Open
hkayngvip opened this issue Sep 29, 2016 · 1 comment

Comments

@hkayngvip
Copy link

barcontroller之后,点击评论弹出键盘,输入框被键盘遮盖,手动改变_inputView的 Y 值无效。不使用uitabbarcontroller没问题,使用uitabbarcontroller之后就出现遮盖问题

@linbo8303
Copy link

linbo8303 commented Jan 23, 2017

在CommentInputView.m里修改

#define InputViewHeightOffset 64      // the height of navigationBar

-(void) addNotify
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardHide:) name:UIKeyboardWillHideNotification object:nil];
}

-(void) removeNotify
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];

}

-(void) onKeyboardShow:(NSNotification *) notify      // typo
{
    NSDictionary *info = notify.userInfo;
    CGRect frame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    _keyboardAnimationDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    _keyboardAnimationCurve = [[info objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];
    
    [self changeInputViewOffsetY:(frame.origin.y - InputViewHeight - InputViewHeightOffset)];
    
}

// change inputView when keyboard hide
- (void) onKeyboardHide:(NSNotification *) notify
{
    NSDictionary *info = notify.userInfo;
    CGRect frame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    _keyboardAnimationDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    _keyboardAnimationCurve = [[info objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];
    
    [self changeInputViewOffsetY:(frame.origin.y - InputViewHeight - InputViewHeightOffset) ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants