Joern Boegeholz
Joern Boegeholz

Reputation: 591

UIGraphicsGetCurrentContext() returns nil -what now?

I'm writing an iOS application and integrated FDWaveformView 2.0.0 via CocoaPods. Sometimes UIGraphicsGetCurrentContext() returns nil and I get the "FDWaveformView failed to get graphics context" log message.

   guard let context = UIGraphicsGetCurrentContext() else {
        NSLog("FDWaveformView failed to get graphics context")
        return
    }

Does anyone know how to solve this issue?

Upvotes: 0

Views: 4129

Answers (2)

Sagar D
Sagar D

Reputation: 223

Ensure that You are calling UIGraphicsGetCurrentContext() inside draw(_ rect : CGRect)() method.

Also ensure that you are not manually calling draw(_ rect : CGRect). Instead call setNeedsDisplay() which will call draw(_ rect : CGRect).

Upvotes: 3

Joern Boegeholz
Joern Boegeholz

Reputation: 591

I solved the issue by updating to 2.1.0

Upvotes: 0

Related Questions