ios - 使用 FLAnimatedImage 的示例或演示 SWIFT 代码

标签 ios swift gif animated-gif

我正在尝试将 FLAnimatedImage 合并到我基于 Swift 的 iOS 应用程序中以显示动画 GIF。

我开始导入 FLAnimatedImage.hFLAnimatedImageView.m 文件,并毫无问题地创建了 Bridging-Header.h

我尝试使用以下代码将 Gif 加载到我的 ImageView 中:

@IBOutlet weak var animatedImageView: FLAnimatedImageView! = animatedImageView.animatedImage = FLAnimatedImage(animatedGIFData: NSData(contentsOfFile: "chicken.gif")) `  

但它在应用程序启动时失败,错误代码如下:

exception 'NSInvalidArgumentException', reason: '-[UIImageView setAnimatedImage:]: unrecognized selector sent to instance 0x78e3c820'

关于如何修复上述错误有什么建议吗?

感谢您的帮助。

最佳答案

import UIKit
class ViewController: UIViewController {
@IBOutlet weak var gifView: FLAnimatedImageView!
override func viewDidLoad() {
  super.viewDidLoad()
  print("\(gifView)")
  if let path =  NSBundle.mainBundle().pathForResource("rock", ofType: "gif") {
    if let data = NSData(contentsOfFile: path) {
      let gif = FLAnimatedImage(animatedGIFData: data)
      gifView.animatedImage = gif
    }
  }
}
}

顺便问一下,您是否在 Storyboard中从 FLAnimatedImageView 子类化了您的 animatedImageView

关于ios - 使用 FLAnimatedImage 的示例或演示 SWIFT 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33217510/

相关文章:

sockets - 电子邮件中的倒计时器图像 GIF

ios - 我无法在 ios Xcode 上运行我的 react-native 应用程序

iphone - Xcode 4.5 的 Storyboard

rotation - 使用 imagemagick 旋转透明 gif

swift - 快速访问navigationController subview 的项目

ios - 在 Parse iOS 中更新对象,[错误] : Object not found

node.js - 如何在 NodeJs 中使用 Canvas 加载 GIF 图像?

ios - NSOperationQueue Heisenbug?

android - 如何在没有我的应用程序的情况下阻止 Eddystone 将内容推送到手机

arrays - Swift HTTP POST 二维数组