我正面臨着我的代碼問題。我似乎無法創建一個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