• <bdo id='Rd0S2'></bdo><ul id='Rd0S2'></ul>

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

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

      1. <tfoot id='Rd0S2'></tfoot>
        <legend id='Rd0S2'><style id='Rd0S2'><dir id='Rd0S2'><q id='Rd0S2'></q></dir></style></legend>

        UIImageView+animatedGIF 总是 LOOPS

        时间:2024-04-14

          <tbody id='sJza2'></tbody>
        <tfoot id='sJza2'></tfoot>

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

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

            • <bdo id='sJza2'></bdo><ul id='sJza2'></ul>
                • 本文介绍了UIImageView+animatedGIF 总是 LOOPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用了由mayoff"(Rob Mayoff)UIImageView+animatedGIF"制作的类,这是在 stackoverflow 上的答案之一中提出的.UIImageView+animatedGIF

                  I used class made by "mayoff" (Rob Mayoff) "UIImageView+animatedGIF" which was proposed in one of the answers here on stackoverflow. UIImageView+animatedGIF

                  有了它,我可以在 iOS 上的 UIImageView 中导入动画 .gif 图像.这个类完美无缺,但唯一的问题是 .gif 总是循环播放.无论我如何导出它(我从 photoshop 导出图像 - 67 帧,将重复设置为一次"),它都会在 UIImageView 中永远循环.

                  With it I can import animated .gif images in UIImageView on iOS. This class works flawlessly, but the only problem is that .gif is always looping. No matter how I export it (I am exporting image from photoshop - 67 frames, set repeat to "once") it loops forever in UIImageView.

                  我正在用这两行导入我的 .gif:

                  I am importing my .gif with these two lines:

                  NSURL *url = [[NSBundle mainBundle] URLForResource:@"Loading" withExtension:@"gif"];
                  self.loadingImageView.image = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
                  

                  非常简单,而且很有效.我尝试按照 Rob 的建议将 animationRepeatCount 属性设置为 1,但这并没有成功.我也尝试将 UIImageView 的 animationImages 属性设置为gifImage.images 也是,而不仅仅是设置视图的图像属性到 gif 图像.在这种情况下,.gif 根本没有动画效果.

                  very simple and it works. I have tried setting animationRepeatCount property to 1, as recomended by Rob but that didn't do the trick. Also I have tried setting the UIImageView's animationImages property to gifImage.images too, instead of just setting the view's image property to gifImage. In that case, .gif is not animating at all.

                  知道如何只播放一次 .gif 吗?我能想到很多技巧(比如设置 gif 的最后一帧在一段时间后显示,但如果可能,我会先尝试一些更简单的方法).

                  Any ideas how to play that .gif only once? I can think of many tricks (like setting last frame of the gif to show up after some time but I'd first try something simpler if possible).

                  推荐答案

                  我从那个项目中取出了测试应用程序并将 viewDidLoad 方法更改为:

                  I took the test app from that project and changed the viewDidLoad method to this:

                  - (void)viewDidLoad {
                      [super viewDidLoad];
                  
                      NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"gif"];
                      UIImage *testImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
                      self.dataImageView.animationImages = testImage.images;
                      self.dataImageView.animationDuration = testImage.duration;
                      self.dataImageView.animationRepeatCount = 1;
                      self.dataImageView.image = testImage.images.lastObject;
                      [self.dataImageView startAnimating];
                  }
                  

                  当应用启动时,它会为图像设置一次动画,然后仅显示最后一帧.如果我连接一个发送 [self.dataImageView startAnimating] 的按钮,然后点击该按钮再次运行动画,然后在最后一帧再次停止.

                  When the app launches, it animates the image once and then shows just the last frame. If I connect a button that sends [self.dataImageView startAnimating], then tapping the button runs the animation one more time, then stops again on the last frame.

                  确保按照我上面的方式设置图像视图.确保您将图像视图的 image 属性设置为动画图像.如果要停止动画,则必须将图像视图的 image 属性设置为非动画图像.

                  Make sure you're setting your image view up the way I do above. Make sure you are not setting the image view's image property to the animated image. The image view's image property must be set to a non-animated image if you want the animation to stop.

                  这篇关于UIImageView+animatedGIF 总是 LOOPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为 UIImage 或 UIImageView 设置动画? 下一篇:如何将 UIImage 和图像数据旋转 90 度

                  相关文章

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

                    <tfoot id='u0HXr'></tfoot>

                      <bdo id='u0HXr'></bdo><ul id='u0HXr'></ul>

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

                    1. <legend id='u0HXr'><style id='u0HXr'><dir id='u0HXr'><q id='u0HXr'></q></dir></style></legend>