【问题标题】:Ionic framework view transition is breaking离子框架视图转换正在中断
【发布时间】:2015-09-24 22:22:57
【问题描述】:

这是一个奇怪的问题。我的(第一个)应用程序中有几个选项卡,每个选项卡都有几个不同的视图。是的,最后一个要编码的标签让我很伤心。

使用桌面浏览器时绝对没有问题 - 没有损坏的 JS,动画流畅,一切看起来都很棒,因为我在选项卡仪表板中从视图 1 转换到视图 2,然后从视图 2 转换到视图 3。

当我构建应用程序并在我的 iPhone (5) 上尝试时,视图 1 和 2 之间的过渡要么完全中断(中途停止),要么在登陆视图 2。在视图 2 和视图 3 之间可以/确实发生同样的情况。当我去检查其他不相关的选项卡/视图时,这永远不会发生。

我真的完全不知所措,因为这种行为只发生在移动设备上的这 3 个视图中。桌面测试环境没有任何反应。

我没有要显示的代码,因为我不知道从哪里开始编写代码。没有 JS 错误,什么都没有。我已经注释掉了大部分相关控制器的 JS 和 .html 视图代码,只是将 $timoeut 与 $state.go 放在了视图之间导航(而不是按下按钮)并且发生了同样的问题。

有什么想法吗?这真的让我很头疼。

谢谢。

ps。为了获得代码,我将为这些视图添加我的路由器代码,因为它几乎是唯一没有被注释掉的代码 - 尽管这个路由器代码与我的应用程序的其余部分非常相似(并且到目前为止没有问题):

       .state('tab.dashboard-add-step-1', {
            url: '/dashboard-add-step-1',
            cache: false,
            data: {
                requireLogin: true
            },
            views: {
                'tab-dashboard': {
                    templateUrl: 'templates/tab-dashboard-add-step-1.html',
                    controller: 'DashboardAddStepOneCtrl as dashboardAddStepOne'
                }
            }
        })
        .state('tab.dashboard-add-step-2', {
            url: '/dashboard-add-step-2',
            cache: false,
            params: {
                'listing': null
            },
            data: {
                requireLogin: true
            },
            views: {
                'tab-dashboard': {
                    templateUrl: 'templates/tab-dashboard-add-step-2.html',
                    controller: 'DashboardAddStepTwoCtrl as dashboardAddStepTwo'
                }
            }
        })
        .state('tab.dashboard-add-step-3', {
            url: '/dashboard-add-step-3',
            cache: false,
            params: {
                'listing':              null,
                'listingAttributes':    null
            },
            data: {
                requireLogin: true
            },
            views: {
                'tab-dashboard': {
                    templateUrl: 'templates/tab-dashboard-add-step-3.html',
                    controller: 'DashboardAddStepThreeCtrl as dashboardAddStepThree'
                }
            }
        })

更新,变得更奇怪了: 我似乎已将问题缩小到在步骤之间进行转换的功能。但是,如果从 $timeout 调用,该函数工作得非常好/过渡很顺利。但是当被 ng-click 或 ng-submit 调用时,它的行为很糟糕(跳跃/中断的过渡)。

这是简单的代码:

    $scope.doStepOne = function() {       
        $state.go('tab.dashboard-add-step-2'); 
    };

    $scope.timer = $timeout(function() {
       $scope.doStepOne(); //the transition when called from here works perfectly         
    }, 5000);

但是当从 ng-submit 或 ng-click 调用相同的函数时,过渡是混乱/丑陋的:

  <button class="button button-calm" ng-click="doStepOne()"> Continue to Step 2</button>

有什么想法吗?我看不出对函数的基于事件的调用与 $timeout 的行为有何不同。

【问题讨论】:

    标签: angularjs ionic-framework ionic


    【解决方案1】:

    原来是iOS9相关的问题,我在iOS8的设备上试了一下,效果很好。

    .....这导致我找到解决问题的以下补丁,耶!!

    信息:

    http://blog.ionic.io/ios-9-potential-breaking-change/

    补丁:

    https://gist.github.com/IgorMinar/863acd413e3925bf282c

    【讨论】:

      猜你喜欢
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多