作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用这个 block ,我的应用程序每次尝试都会崩溃
CGImageDestinationFinalize(gifDest!)
阻止
func createGIF(with images: [CGImage], data: Data, loopCount: Int, frameDelay: Double) -> Data {
print("()createGIF.HandHistoryTableVC")
let gifDest = CGImageDestinationCreateWithData(data as! CFMutableData, kUTTypeGIF, images.count, nil)
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: loopCount]]
CGImageDestinationSetProperties(gifDest!, fileProperties as CFDictionary?)
let frameProperties = [(kCGImagePropertyGIFDictionary as String): [(kCGImagePropertyGIFDelayTime as String): frameDelay]]
for img in images {
CGImageDestinationAddImage(gifDest!, img, frameProperties as CFDictionary?)
}
print("GIF in Progress")
CGImageDestinationFinalize(gifDest!)
print("gifMade")
return data;
}
错误报告
我不知道这次事故的原因。所有关于“线程 1:信号 SIGABRT”的研究似乎都说这是一个连接问题,但如果我注释掉 CGImageDestinationFinalize(),我的整个应用程序工作正常
最佳答案
func createGIF(with images: [CGImage], data: CFMutableData, loopCount: Int, frameDelay: Double) -> Data {
print("()createGIF.HandHistoryTableVC")
let gifDest = CGImageDestinationCreateWithData(data, kUTTypeGIF, images.count, nil)
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: loopCount]]
CGImageDestinationSetProperties(gifDest!, fileProperties as CFDictionary?)
let frameProperties = [(kCGImagePropertyGIFDictionary as String): [(kCGImagePropertyGIFDelayTime as String): frameDelay]]
for img in images {
CGImageDestinationAddImage(gifDest!, img, frameProperties as CFDictionary?)
}
print("GIF in Progress")
CGImageDestinationFinalize(gifDest!)
print("gifMade")
return data as Data;
}
使用 CFMutableData 初始值设定项
CFDataCreateMutable(kCFAllocatorDefault, 0)
解决了这个问题。
关于swift - 是线程 1 : signal SIGABRT always a connection issue (cgimagedestinationfinalize),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42753496/
我是一名优秀的程序员,十分优秀!