问题
I'm getting video thumbnails asynchronously with the following code:
let imgGenerator = AVAssetImageGenerator(asset: asset)
imgGenerator.generateCGImagesAsynchronouslyForTimes([NSValue(CMTime: CMTimeMake(1, 30))]) {(time1, image, time2, result, error) -> Void in
if (result == .Succeeded) {
dispatch_async(dispatch_get_main_queue()) {
thumbnailImageView.image = UIImage(CGImage: image!)
}
NSLog("SUCCESS!")
}
}
I don't understand why it freezes the app but for example if I use this for 20 tableview cells it takes more than 20 seconds to load and the app will not segue and show the view before it finishes downloading all. Why am I missing here ?
来源:https://stackoverflow.com/questions/37394920/ios-swift-generatecgimagesasynchronouslyfortimes-takes-too-long-and-freezes-th