• <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

        UIImageView+animatedGIF always LOOPS(UIImageView+animatedGIF 总是 LOOPS)

          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  what#39;s property copy means in Cocoa#39;s Framework?(like UITabBar#39;s items property)(Cocoa 框架中的属性副本是什么意思?(如 UITabBar 的 items 属性))
                  Can`t copy file from bundle to documents directory in iOS(无法将文件从捆绑包复制到 iOS 中的文档目录)
                  Automatically copy property values from one object to another of a different type but the same protocol (Objective-C)(自动将属性值从一个对象复制到另一个类型不同但协议相同的对象 (Objective-C))
                  Copy text to clipboard with iOS(使用 iOS 将文本复制到剪贴板)
                  How to copy text to clipboard/pasteboard with Swift(如何使用 Swift 将文本复制到剪贴板/粘贴板)
                  How to show the progress of copying a large file in iOS?(如何在iOS中显示复制大文件的进度?)
                    <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>
                          <tbody id='u0HXr'></tbody>

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

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