我正面临着我的代码问题。我似乎无法创建一个CGImageSource
/CGImageSourceRef
,但是我看到的每个回购都使用了完全相同的方法。我已经测试过,看看数据对象是否包含gif
,并且它确实如此。所以我已经将此错误隔离为CGImageSourceCreateWithData
函数,我不知道如何解决它。任何帮助,将不胜感激。CGImageSourceCreateWithData将继续生成错误
这里的错误:
warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.
它使具有这种功能特别失败:
var imgSource = CGImageSourceCreateWithData(data, nil)
这里是我的简单的代码,保持失败:
import UIKit
import ImageIO
import MobileCoreServices
import AVFoundation
class LCGIFImage: UIImage {
//MARK: Initializers
convenience override init?(contentsOfFile path: String) {
let data = NSData(contentsOfURL: NSURL(string: path)!)
self.init(data: data!)
}
convenience override init?(data: NSData) {
self.init(data: data, scale: 1.0)
}
override init?(data: NSData, scale: CGFloat) {
var imgSource = CGImageSourceCreateWithData(data, nil)
super.init(data: data, scale: scale)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
required convenience init(imageLiteral name: String) {
fatalError("init(imageLiteral:) has not been implemented")
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let path = NSBundle.mainBundle().URLForResource("1", withExtension: "gif")?.absoluteString as String!
let test = LCGIFImage(contentsOfFile: path)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
令路径= NSBundle.mainBundle()pathForResource( “1”,ofType: “GIF”)。 –
@LeoDabus感谢。但是,这个问题不在路径中。它能够找到gif文件。这是'CGImageSourceCreateWithData'函数一直给我的警告:无法加载任何Objective-C类信息。这将显着降低可用类型信息的质量。 – iamktothed