• vue项目类微信聊天页面,输入法弹出,ios的标题会整体上移问题


    场景:vue项目类微信聊天页面等,有输入框可以唤起输入法弹出

    问题:ios移动端,当输入法弹出,整体页面会上移,导致标题等元素上移出视图窗口

    解决方案:

    ios的壳改代码,通过监听键盘事件,然后再让其窗口向下滚动到底部。
     1:监听键盘
      2:键盘弹出-窗口向下滚动到底部
    1. // 监听键盘
    2. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowAction:) name:UIKeyboardWillShowNotification object:nil];
    3. /**
    4. * 键盘即将弹出
    5. */
    6. - (void)keyboardWillShowAction:(NSNotification *)note{
    7. CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    8. CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    9. NSLog(@"高度 ===%f",keyboardF.size.height);
    10. NSDictionary *dic = @{
    11. @"keyboardHeight":[NSString stringWithFormat:@"%f",keyboardF.size.height],
    12. @"keyboardTime":[NSString stringWithFormat:@"%f",duration],
    13. };
    14. NSString *jsStr = [NSString stringWithFormat:@"%@('%@')",@"showKeyboardHeight",[self.interactive convertToJsonData:dic]];
    15. [self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
    16. NSLog(@"%@----%@",result, error);
    17. }];
    18. }
    19. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    20. NSLog(@"scrollView ==%@",scrollView);
    21. //解决H5聊天界面 底部输入框 点击后键盘弹出 界面上移问题
    22. scrollView.contentOffset = CGPointMake(0, 0);
    23. }

  • 相关阅读:
    Flask框架中Jinja2模板过滤器
    观察者模式
    [C++]ifstream和getline获取中文乱码解决方案
    LeetCode-1135. Connecting Cities With Minimum Cost [C++][Java]
    27、用户操作srv、web服务实现
    拯救低效率,强烈推荐这4款实用的Windows软件
    算法(圆的定义和相关术语)
    Flutter实战之go_router路由组件入门指南
    东极岛 需要提早买门票
    9_19,洛谷刷题记录
  • 原文地址:https://blog.csdn.net/yyhjifeng/article/details/133747187