帖子
帖子
用户
博客
课程
显示全部楼层
1
帖子
0
勋章
23
Y币

[其他] IOS下setFrameGroupIndex不能与setFrameGroupAttr共存BUG

[复制链接]
发表于 2022-1-10 22:31:37
本帖最后由 BIP322802 于 2022-1-10 22:48 编辑

情境:APP底部导航切换用了FrameGroup,点击导航菜单后调用setFrameGroupIndex切换页面,同时调用了setFrameGroupAttr设置不同页面的rect(有的页面有头部,有的没有)
BUG:安卓一切正常,当苹果loder调试时,只要页面尺寸rect变了,setFrameGroupIndex就不生效,表现为:页面实际没切换,只是头部切换了。
调试:当给setFrameGroupAttr加延时至少500时、或者去掉这个,苹果则回复正常。
代码:


  1. <footer class="aui-bar aui-bar-tab">
  2.     <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item aui-active" tapmode="hover">
  3.         <img src="./image/root/nav/11.png" alt="">
  4.         <div class="aui-bar-tab-label">首页</div>
  5.     </div>
  6.     <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
  7.         <img src="./image/root/nav/22.png" alt="">
  8.         <div class="aui-bar-tab-label">资讯</div>
  9.     </div>
  10.     <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
  11.         <img src="./image/root/nav/32.png" alt="">
  12.         <div class="aui-bar-tab-label">商城</div>
  13.     </div>
  14.     <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
  15.         <img src="./image/root/nav/42.png" alt="">
  16.         <div class="aui-bar-tab-label">游戏</div>
  17.     </div>
  18.     <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
  19.         <img src="./image/root/nav/52.png" alt="">
  20.         <div class="aui-bar-tab-label">我的</div>
  21.     </div>
  22. </footer>


  23. <script type="text/javascript">
  24. // 底部按钮切换
  25. function randomSwitchBtn(tag) {
  26.     if (tag == $api.dom('footer .aui-bar-tab-item.aui-active')) return;
  27.     var eFootLis = $api.domAll('footer .aui-bar-tab-item'),
  28.         eHeaderLis = $api.domAll('header li'),
  29.         index = 0,
  30.         reload = false;
  31.     //需要登录的frm
  32.     if (tag == eFootLis[2] || tag == eFootLis[3] || tag == eFootLis[4]) {
  33.         if (!km_islogin_app()) { //未登录
  34.             km_open_win('public/login_win', false);
  35.             return;
  36.         }
  37.     }
  38.     //需要刷新
  39.     if (tag == eFootLis[2] || tag == eFootLis[3]) {
  40.         reload = true;
  41.     }
  42.     //底部菜单图标class切换
  43.     for (var i = 0; i < eFootLis.length; i++) {
  44.         if (tag == eFootLis[i]) {
  45.             $api.addCls(eFootLis[i], 'aui-active');
  46.             eFootLis[i].childNodes[0].src = './image/root/nav/' + (i + 1) + '1.png';
  47.             // $api.addCls(eHeaderLis[i], 'aui-active');
  48.             //frame判断
  49.             index = i
  50.         } else {
  51.             $api.removeCls(eFootLis[i], 'aui-active');
  52.             eFootLis[i].childNodes[0].src = './image/root/nav/' + (i + 1) + '2.png';
  53.             // $api.removeCls(eHeaderLis[i], 'aui-active');
  54.         }
  55.     }
  56.     // 切换frm内容
  57.     api.setFrameGroupIndex({
  58.         name: 'group_root',
  59.         index: index,
  60.         scroll: true, //是否平滑滚动至目标窗口,即是否带有动画
  61.         reload: reload, //是否刷新 frame
  62.     });
  63.     // 通过改变rect实现显示隐藏win的标题栏
  64.     if (tag == eFootLis[0]) {
  65.         rect = {
  66.             x: 0,
  67.             y: $api.offset($api.dom('header')).h - 2,
  68.             w: 'auto',
  69.             h: $api.offset($api.dom('footer')).t - $api.offset($api.dom('header')).h + 2
  70.         };
  71.     } else {
  72.         rect = {
  73.             x: 0,
  74.             y: 0,
  75.             w: 'auto',
  76.             h: $api.offset($api.dom('footer')).t + 1
  77.         };
  78.     }
  79.     // setTimeout(function() {
  80.         api.setFrameGroupAttr({
  81.             name: 'group_root',
  82.             rect: rect,
  83.         });
  84.     // }, 500);

  85. }
  86. </script>
复制代码


1
帖子
0
勋章
23
Y币
本帖最后由 BIP322802 于 2022-1-10 22:48 编辑

有大佬遇到这种情况吗
1
帖子
0
勋章
23
Y币
自己换种写法已解决:

把setFrameGroupAttr方法改写在openFrameGroup的回调里
380
帖子
4
勋章
6
Y币
OK
您需要登录后才可以回帖 登录

本版积分规则