• <i id='svQkc'><tr id='svQkc'><dt id='svQkc'><q id='svQkc'><span id='svQkc'><b id='svQkc'><form id='svQkc'><ins id='svQkc'></ins><ul id='svQkc'></ul><sub id='svQkc'></sub></form><legend id='svQkc'></legend><bdo id='svQkc'><pre id='svQkc'><center id='svQkc'></center></pre></bdo></b><th id='svQkc'></th></span></q></dt></tr></i><div id='svQkc'><tfoot id='svQkc'></tfoot><dl id='svQkc'><fieldset id='svQkc'></fieldset></dl></div>

    <small id='svQkc'></small><noframes id='svQkc'>

      <legend id='svQkc'><style id='svQkc'><dir id='svQkc'><q id='svQkc'></q></dir></style></legend>
      1. <tfoot id='svQkc'></tfoot>
        • <bdo id='svQkc'></bdo><ul id='svQkc'></ul>

        UINavigationController 推送过渡期间的低帧率

        时间:2023-06-12
          <bdo id='8xRZe'></bdo><ul id='8xRZe'></ul>

            1. <i id='8xRZe'><tr id='8xRZe'><dt id='8xRZe'><q id='8xRZe'><span id='8xRZe'><b id='8xRZe'><form id='8xRZe'><ins id='8xRZe'></ins><ul id='8xRZe'></ul><sub id='8xRZe'></sub></form><legend id='8xRZe'></legend><bdo id='8xRZe'><pre id='8xRZe'><center id='8xRZe'></center></pre></bdo></b><th id='8xRZe'></th></span></q></dt></tr></i><div id='8xRZe'><tfoot id='8xRZe'></tfoot><dl id='8xRZe'><fieldset id='8xRZe'></fieldset></dl></div>
            2. <tfoot id='8xRZe'></tfoot>
              • <small id='8xRZe'></small><noframes id='8xRZe'>

                  <legend id='8xRZe'><style id='8xRZe'><dir id='8xRZe'><q id='8xRZe'></q></dir></style></legend>
                    <tbody id='8xRZe'></tbody>
                  本文介绍了UINavigationController 推送过渡期间的低帧率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 UINavigationController,并从根视图控制器推送到下一个视图控制器.第二个视图控制器相当重",因为它有大量的初始化和子视图.

                  I have a UINavigationController, and push from the root view controller to the next view controller. This second view controller is fairly "heavy", in that it has a great deal of initialization and subviews.

                  我的问题是:过渡动画的表现非常糟糕.基本上,动画的帧速率非常低(我从推送"动画中总共获得了 3-4 帧).

                  My issue is this: the transition animation performs terribly. Basically, the animation suffers from a very low frame rate (I get maybe 3-4 frames in total out of the "push" animation).

                  我尝试了多种不同的技术,包括两种不同的手动动画过渡方法.在所有情况下,动画的前 0.4-0.7 秒都会受到这种低帧率的影响.例如,如果我将过渡时间设置为 5 秒,那么前半秒左右的效果会很差,但动画的其余部分却很流畅.

                  I've tried a variety of different techniques, including two different methods to manually animate the transition. In all cases, the first 0.4-0.7 seconds of the animation suffers from this poor framerate. If I set the transition to take 5 seconds, for example, the first half second or so performs poorly, but the remainder of the animation is nice and smooth.

                  这让我相信在过渡开始时某事"正在发生——导致设备以非常低的帧速率进行动画处理.

                  This leads me to believe that "something" is happening at the beginning of the transition -- something which causes the device to animate at a very low framerate.

                  在我的代码中注入大量 NSLog 语句后,我看到发生了两件事.首先,显然第二个视图在推送期间被延迟加载.我通过在执行推送之前访问 view 属性上的 getter 来解决这个问题.我可以确认这会导致在推送动画开始之前发生所有初始化.

                  After injecting a lot of NSLog statements into my code, I saw two things happen. First, obviously the second view is being lazy-loaded during the push. I fixed this by accessing the getter on the view property before executing the push. I can confirm that this results in all the initialization happening before the push animation begins.

                  其次,我的应用在转换过程中大部分时间都会收到内存不足的警告.然而,即使在我没有收到内存警告的情况下,动画的表现仍然很差——这让我相信这些都不是原因.

                  Second, my app most of the time receives a low memory warning during the transition. However, even in cases when I don't get the memory warning, the animation still performs just as poorly -- leading me to believe that neither of these things is the cause.

                  我的问题:是否有其他人在 UINavigationController 推送过渡动画上遇到过低帧率,但仅在动画的前 0.4-0.7 秒?幕后是否还有其他事情导致它发生,有什么办法吗?

                  My question: Has anyone else experienced a low framerate on a UINavigationController push transition animation, but only for the first 0.4-0.7 seconds of the animation? Is there something else going on behind the scenes that causes it, and can anything be done?

                  作为参考,这是我当前加载并推送到下一个视图的代码.我有目的地访问视图获取器,以强制视图在转换之前加载和初始化(主要是为了排除这个问题).此代码使用 performSelectorOnMainThread::: 在主线程上执行,以响应 Web 服务回调.

                  For reference, here's my current code that loads and pushes to the next view. I'm purposefully accessing the view getter in order to force the view to load and initialize before the transition (mostly to rule out that as the issue). This code is executed on the main thread using performSelectorOnMainThread::: in response to a web service callback.

                  PlayingFieldViewController *v = [[PlayingFieldViewController alloc] initWithNibName:@"PlayingFieldView" bundle:[NSBundle mainBundle]];
                  UIView *lazy = v.view;
                  [appDelegate.navigationController pushViewController:v animated:YES];
                  [v release];
                  

                  我还尝试了其他一些动画技术,结果都一样:

                  I've also tried a few other animation techniques, all with the same result:

                  CATransition *transition = [CATransition animation];
                  transition.duration = 1.0;
                  transition.type = kCATransitionPush;
                  transition.subtype = kCATransitionFromRight;
                  [appDelegate.navigationController.view.layer addAnimation:transition forKey:kCATransition];
                  [appDelegate.navigationController pushViewController:v animated:NO];
                  

                  和:

                  [UIView 
                    transitionWithView:appDelegate.navigationController.view
                    duration:1.0
                    options:UIViewAnimationOptionTransitionCurlUp
                    animations:^{
                     [appDelegate.navigationController pushViewController:v animated:NO];
                    }
                    completion:NULL];
                  

                  推荐答案

                  经过进一步测试,我能够诊断出问题.涉及的第二个视图包括许多 UIImageViews.删除这些视图或隐藏它们可以解决问题.

                  After further testing, I was able to diagnose the problem. The second view involved includes many UIImageViews. Removing those views or hiding them fixes the problem.

                  令我失望的是,只有动画的第一部分存在帧速率问题,而动画的其余部分却非常流畅(在较长动画的情况下).这向我表明,即使所有子视图都存在,该设备也能够流畅地制作过渡动画.

                  What threw me off was the fact that only the first portion of the animation suffered from frame rate issues, while the remainder of the animation was perfectly smooth (in the case of longer animations). This shows me that the device is quite capable of animating the transition smoothly, even with all the subviews present.

                  我仍然不是 iOS 合成方面的专家,但我猜测正在布局和缓存各个层,从而导致速度变慢.解决方法是推到隐藏大部分子视图的视图,然后在视图可见时使用另一个动画显示它们.

                  I'm still not an expert on iOS compositing, but I'm guessing the various layers are being laid out and cached, leading to the slowdown. The workaround is to push to the view with most of the subviews hidden, then show them using another animation once the view is visible.

                  这篇关于UINavigationController 推送过渡期间的低帧率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将 UISegmentedControl 放在 NavigationController 下? 下一篇:嵌套推送动画可能导致导航栏损坏多次警告

                  相关文章

                    <legend id='lT3pj'><style id='lT3pj'><dir id='lT3pj'><q id='lT3pj'></q></dir></style></legend>
                      <bdo id='lT3pj'></bdo><ul id='lT3pj'></ul>
                    1. <small id='lT3pj'></small><noframes id='lT3pj'>

                    2. <tfoot id='lT3pj'></tfoot>

                    3. <i id='lT3pj'><tr id='lT3pj'><dt id='lT3pj'><q id='lT3pj'><span id='lT3pj'><b id='lT3pj'><form id='lT3pj'><ins id='lT3pj'></ins><ul id='lT3pj'></ul><sub id='lT3pj'></sub></form><legend id='lT3pj'></legend><bdo id='lT3pj'><pre id='lT3pj'><center id='lT3pj'></center></pre></bdo></b><th id='lT3pj'></th></span></q></dt></tr></i><div id='lT3pj'><tfoot id='lT3pj'></tfoot><dl id='lT3pj'><fieldset id='lT3pj'></fieldset></dl></div>