Skip to content

Commit

Permalink
Merge pull request #75 from steryokhin/master
Browse files Browse the repository at this point in the history
Fix layoutSubviews call from background thread
  • Loading branch information
fulldecent authored Dec 3, 2016
2 parents 47c9ec9 + fd07880 commit 355911b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Source/FDWaveformView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ open class FDWaveformView: UIView {
if let asbd = CMAudioFormatDescriptionGetStreamBasicDescription(item) {
let samples = (asbd.pointee.mSampleRate) * Float64(asset.duration.value) / Float64(asset.duration.timescale)

self.imageView.image = nil
self.highlightedImage.image = nil
self.progressSamples = 0
self.zoomStartSamples = 0
self.totalSamples = Int(samples)
self.zoomEndSamples = Int(samples)
self.setNeedsDisplay()
self.performSelector(onMainThread: #selector(self.setNeedsLayout), with: nil, waitUntilDone: false)
DispatchQueue.main.async {
self.imageView.image = nil
self.highlightedImage.image = nil
self.progressSamples = 0
self.zoomStartSamples = 0
self.totalSamples = Int(samples)
self.zoomEndSamples = Int(samples)
self.setNeedsDisplay()
self.setNeedsLayout()
}
}
}
case .failed, .cancelled, .loading, .unknown:
Expand Down

0 comments on commit 355911b

Please sign in to comment.